[Checkins] SVN: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/
primary_key must be a sequence of Column() instances,
Andreas Jung
andreas at andreas-jung.com
Tue Apr 24 01:31:43 EDT 2007
Log message for revision 74694:
primary_key must be a sequence of Column() instances,
not column names
Changed:
U z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/CHANGES.txt
U z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py
-=-
Modified: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/CHANGES.txt
===================================================================
--- z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/CHANGES.txt 2007-04-24 05:20:56 UTC (rev 74693)
+++ z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/CHANGES.txt 2007-04-24 05:31:43 UTC (rev 74694)
@@ -7,7 +7,12 @@
model with a BoundMetaData instance in order to allow
table auto-loading
+ - Model.add() got a new parameter 'primary_key' in order to specify a
+ primary_key hint. This is useful when you are trying to auto-load a view
+ as Table() having no primary key information. The 'primary_key' parameter
+ is either None or a sequence of column names.
+
0.1.8 (23.04.2007)
- added shorter method names as aliases
Modified: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py
===================================================================
--- z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py 2007-04-24 05:20:56 UTC (rev 74693)
+++ z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py 2007-04-24 05:31:43 UTC (rev 74694)
@@ -144,17 +144,18 @@
# pre-configured primary_key parameter?
- primary_key = self._model.get(name, {}).get('primary_key')
+ primary_key = self._model.get(name, {}).get('primary_key', None)
+
if isinstance(primary_key, (list, tuple)):
+ # The 'primary_key' hint is configured as a list/tuple of
+ # column names. However the mapper() method requires
+ # a sequence of the related Column() instances
primary_key = [getattr(table.c, pk) for pk in primary_key]
# create a mapper and cache it
-
if mapper_class and mapper_class.__dict__.has_key('c'):
mapper = mapper_class
-
else:
-
mapper = self._mapper_factory(table,
properties=properties,
primary_key=primary_key,
More information about the Checkins
mailing list