summaryrefslogtreecommitdiff
path: root/test/ext/declarative.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-08-04 15:21:29 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-08-04 15:21:29 +0000
commitd371637af055805f347ad177f5b457bccbbc3150 (patch)
tree890539bd5cecfe9b42aeb57546edf39a658cf599 /test/ext/declarative.py
parent28ff190475b1717a7cb8616a7ad8590c00a9a6c8 (diff)
downloadsqlalchemy-d371637af055805f347ad177f5b457bccbbc3150.tar.gz
- fixed endless loop bug which could occur
within a mapper's deferred load of inherited attributes. - declarative initialization of Columns adjusted so that non-renamed columns initialize in the same way as a non declarative mapper. This allows an inheriting mapper to set up its same-named "id" columns in particular such that the parent "id" column is favored over the child column, reducing database round trips when this value is requested.
Diffstat (limited to 'test/ext/declarative.py')
-rw-r--r--test/ext/declarative.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ext/declarative.py b/test/ext/declarative.py
index 55d9aece8..c1a56ced2 100644
--- a/test/ext/declarative.py
+++ b/test/ext/declarative.py
@@ -567,6 +567,23 @@ class DeclarativeTest(testing.TestBase, testing.AssertsExecutionResults):
any(Engineer.primary_language == 'cobol')).first()),
c2)
+ # ensure that the Manager mapper was compiled
+ # with the Person id column as higher priority.
+ # this ensures that "id" will get loaded from the Person row
+ # and not the possibly non-present Manager row
+ assert Manager.id.property.columns == [Person.__table__.c.id, Manager.__table__.c.id]
+
+ # assert that the "id" column is available without a second load.
+ # this would be the symptom of the previous step not being correct.
+ sess.clear()
+ def go():
+ assert sess.query(Manager).filter(Manager.name=='dogbert').one().id
+ self.assert_sql_count(testing.db, go, 1)
+ sess.clear()
+ def go():
+ assert sess.query(Person).filter(Manager.name=='dogbert').one().id
+ self.assert_sql_count(testing.db, go, 1)
+
def test_inheritance_with_undefined_relation(self):
class Parent(Base):
__tablename__ = 'parent'