summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-08-15 02:02:47 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-08-15 02:02:47 +0000
commit8b313b356e5ba46c892b37fb1105c2de26e4beb2 (patch)
treeeddb815810e97e7ab69347a4b7f3f58de737ff9c /lib/sqlalchemy/orm
parentd73ca890f3fbb6416946abc083b61f467572b7e7 (diff)
downloadsqlalchemy-8b313b356e5ba46c892b37fb1105c2de26e4beb2.tar.gz
- eesh ! the tutorial doctest was broken for quite some time.
- add_property() method on mapper does a "compile all mappers" step in case the given property references a non-compiled mapper (as it did in the case of the tutorial !)
Diffstat (limited to 'lib/sqlalchemy/orm')
-rw-r--r--lib/sqlalchemy/orm/mapper.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index 689b3241b..ab0226a41 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -151,7 +151,17 @@ class Mapper(object):
this is the 'external' version of the method which is not reentrant."""
if self.__is_compiled:
return self
-
+
+ self._compile_all()
+
+ # if we're not primary, compile us
+ if self.non_primary:
+ self._do_compile()
+ self._initialize_properties()
+
+ return self
+
+ def _compile_all(self):
# compile all primary mappers
for mapper in mapper_registry.values():
if not mapper.__is_compiled:
@@ -162,13 +172,6 @@ class Mapper(object):
if not mapper.__props_init:
mapper._initialize_properties()
- # if we're not primary, compile us
- if self.non_primary:
- self._do_compile()
- self._initialize_properties()
-
- return self
-
def _check_compile(self):
if self.non_primary:
self._do_compile()
@@ -496,6 +499,8 @@ class Mapper(object):
has already been compiled, then the given MapperProperty is compiled immediately."""
self.properties[key] = prop
if self.__is_compiled:
+ # if we're compiled, make sure all the other mappers are compiled too
+ self._compile_all()
self._compile_property(key, prop, init=True)
def _create_prop_from_column(self, column, skipmissing=False):