summaryrefslogtreecommitdiff
path: root/test/inheritance.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-03-22 00:22:26 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-03-22 00:22:26 +0000
commit38594ca1e17fc835da55afad19e34e141ba17b4d (patch)
tree804871d645f0e86e7ad439575e471dd5421c9b0c /test/inheritance.py
parentbc856c44126481c5b523c3102986fbed2fa924a7 (diff)
downloadsqlalchemy-38594ca1e17fc835da55afad19e34e141ba17b4d.tar.gz
added unit test to test proper construction of lazy clause against inherited mapper
Diffstat (limited to 'test/inheritance.py')
-rw-r--r--test/inheritance.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/inheritance.py b/test/inheritance.py
index a3a354c5a..657af8a27 100644
--- a/test/inheritance.py
+++ b/test/inheritance.py
@@ -384,6 +384,48 @@ class InheritTest5(testbase.AssertMixin):
# shouldnt throw exception
products = mapper(Product, product, inherits=contents)
+class InheritTest6(testbase.AssertMixin):
+ """tests eager load/lazy load of child items off inheritance mappers, tests that
+ LazyLoader constructs the right query condition."""
+ def setUpAll(self):
+ global foo, bar, bar_foo
+ foo = Table('foo', testbase.db, Column('id', Integer, Sequence('foo_seq'), primary_key=True),
+ Column('data', String(30))).create()
+ bar = Table('bar', testbase.db, Column('id', Integer, ForeignKey('foo.id'), primary_key=True),
+ Column('data', String(30))).create()
+
+ bar_foo = Table('bar_foo', testbase.db,
+ Column('bar_id', Integer, ForeignKey('bar.id')),
+ Column('foo_id', Integer, ForeignKey('foo.id'))
+ ).create()
+ def tearDownAll(self):
+ bar_foo.drop()
+ bar.drop()
+ foo.drop()
+
+ def testbasic(self):
+ class Foo(object): pass
+ class Bar(Foo): pass
+ foos = mapper(Foo, foo)
+ bars = mapper(Bar, bar, inherits=foos)
+ bars.add_property('lazy', relation(foos, bar_foo, lazy=True))
+ bars.add_property('eager', relation(foos, bar_foo, lazy=False))
+
+ foo.insert().execute(data='foo1')
+ bar.insert().execute(id=1, data='bar1')
+
+ foo.insert().execute(data='foo2')
+ bar.insert().execute(id=2, data='bar2')
+
+ foo.insert().execute(data='foo3') #3
+ foo.insert().execute(data='foo4') #4
+
+ bar_foo.insert().execute(bar_id=1, foo_id=3)
+ bar_foo.insert().execute(bar_id=2, foo_id=4)
+
+ self.assert_(len(bars.selectfirst().lazy) == 1)
+ self.assert_(len(bars.selectfirst().eager) == 1)
+
if __name__ == "__main__":
testbase.main()