summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-05-20 18:16:10 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-05-20 18:16:10 +0000
commit8405d1267c1e271df20d960367db4683ec02decf (patch)
tree98af5702633e43c4235fc4ac10c0008c13f33605 /test
parent555ab611f159d40af9653e8dcd53bf92fd2bd592 (diff)
downloadsqlalchemy-8405d1267c1e271df20d960367db4683ec02decf.tar.gz
restored comparison of 1-element clause list -> ClauseElement, which was broken in [changeset:2620]
Diffstat (limited to 'test')
-rw-r--r--test/orm/mapper.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/orm/mapper.py b/test/orm/mapper.py
index 5c4efb6a9..889a7c925 100644
--- a/test/orm/mapper.py
+++ b/test/orm/mapper.py
@@ -1087,6 +1087,22 @@ class LazyTest(MapperSuperTest):
self.echo(repr(l[0].user))
self.assert_(l[0].user is not None)
+ def testuseget(self):
+ """test that a simple many-to-one lazyload optimizes to use query.get().
+
+ this is done currently by comparing the 'get' SQL clause of the query
+ to the 'lazy' SQL clause of the lazy loader, so it relies heavily on
+ ClauseElement.compare()"""
+
+ m = mapper(Address, addresses, properties = dict(
+ user = relation(mapper(User, users), lazy = True)
+ ))
+ sess = create_session()
+ a1 = sess.query(Address).get_by(email_address = "ed@wood.com")
+ u1 = sess.query(User).get(8)
+ def go():
+ assert a1.user is u1
+ self.assert_sql_count(db, go, 0)
def testdouble(self):
"""tests lazy loading with two relations simulatneously, from the same table, using aliases. """