summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/activemapper.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-10-21 23:15:13 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-10-21 23:15:13 +0000
commit97feb4dbeee3ef5bc50de667ec25a43d44a5ff2c (patch)
tree8914c29df83afc5fae9705d92de9e780d8115138 /lib/sqlalchemy/ext/activemapper.py
parentc9dc3a334eee9bb9e281f5a64251979315079aab (diff)
downloadsqlalchemy-97feb4dbeee3ef5bc50de667ec25a43d44a5ff2c.tar.gz
- docstring on polymorphic_mapping
- applied Simon Wittber's ActiveMapper version_id_col patch for [ticket:348]
Diffstat (limited to 'lib/sqlalchemy/ext/activemapper.py')
-rw-r--r--lib/sqlalchemy/ext/activemapper.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/sqlalchemy/ext/activemapper.py b/lib/sqlalchemy/ext/activemapper.py
index d5fa29a0e..769c70b83 100644
--- a/lib/sqlalchemy/ext/activemapper.py
+++ b/lib/sqlalchemy/ext/activemapper.py
@@ -206,7 +206,9 @@ class ActiveMapperMeta(type):
autoload = False
_metadata = getattr(sys.modules[cls.__module__],
"__metadata__", metadata)
-
+ version_id_col = None
+ version_id_col_object = None
+
if 'mapping' in dict:
found_pk = False
@@ -223,7 +225,10 @@ class ActiveMapperMeta(type):
if '__autoload__' == name:
autoload = True
continue
-
+
+ if '__version_id_col__' == name:
+ version_id_col = value
+
if name.startswith('__'): continue
if isinstance(value, column):
@@ -263,12 +268,16 @@ class ActiveMapperMeta(type):
cls.columns = cls.table._columns
# check for inheritence
+ if version_id_col is not None:
+ version_id_col_object = getattr(cls.table.c, version_id_col, None)
+ assert(version_id_col_object is not None, "version_id_col (%s) does not exist." % version_id_col)
+
if hasattr(bases[0], "mapping"):
cls._base_mapper= bases[0].mapper
assign_mapper(objectstore.context, cls, cls.table,
- inherits=cls._base_mapper)
+ inherits=cls._base_mapper, version_id_col=version_id_col_object)
else:
- assign_mapper(objectstore.context, cls, cls.table)
+ assign_mapper(objectstore.context, cls, cls.table, version_id_col=version_id_col_object)
cls.relations = relations
ActiveMapperMeta.classes[clsname] = cls