diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-05-22 16:47:55 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-05-22 16:47:55 +0000 |
| commit | 4937f49bd8c04f9bec2c2cec5d50b0619ed5b69f (patch) | |
| tree | 7d2c8c651846aae3998d04d79fe4082498ccdecc /test | |
| parent | 2ee1d4042825cf5cb0eb5a6a7659d8398d73a4c3 (diff) | |
| download | sqlalchemy-4937f49bd8c04f9bec2c2cec5d50b0619ed5b69f.tar.gz | |
- improved support for eagerloading of properties off of mappers that are mapped
to select() statements; i.e. eagerloader is better at locating the correct
selectable with which to attach its LEFT OUTER JOIN.
- some fixes to new tests in inheritance5 to work with postgres
Diffstat (limited to 'test')
| -rw-r--r-- | test/orm/inheritance5.py | 4 | ||||
| -rw-r--r-- | test/orm/mapper.py | 21 |
2 files changed, 23 insertions, 2 deletions
diff --git a/test/orm/inheritance5.py b/test/orm/inheritance5.py index 1c4214635..56a83f575 100644 --- a/test/orm/inheritance5.py +++ b/test/orm/inheritance5.py @@ -706,7 +706,7 @@ class GenerativeTest(testbase.AssertMixin): # into the WHERE criterion, using a correlated select. ticket #577 tracks # that Query's adaptation of the WHERE clause does not dig into the # mapped selectable itself, which permanently breaks the mapped selectable. - r = session.query(Person).filter(Car.c.owner == select([Car.c.owner], Car.c.owner==employee_join.c.person_id)) + r = session.query(Person).filter(exists([Car.c.owner], Car.c.owner==employee_join.c.person_id)) assert str(list(r)) == "[Engineer E4, field X, status Status dead]" class MultiLevelTest(testbase.ORMTest): @@ -878,7 +878,7 @@ class CustomPKTest(testbase.ORMTest): # query using get(), using only one value. this requires the select_table mapper # has the same single-col primary key. - assert sess.query(T1).get(ot1.id).id is ot1.id + assert sess.query(T1).get(ot1.id).id == ot1.id ot1 = sess.query(T1).get(ot1.id) ot1.data = 'hi' diff --git a/test/orm/mapper.py b/test/orm/mapper.py index 889a7c925..921b5f9b0 100644 --- a/test/orm/mapper.py +++ b/test/orm/mapper.py @@ -1325,6 +1325,27 @@ class EagerTest(MapperSuperTest): l = m.instances(s.execute(emailad = 'jack@bean.com'), session) self.echo(repr(l)) + + def testonselect(self): + """test eager loading of a mapper which is against a select""" + + s = select([orders], orders.c.isopen==1).alias('openorders') + mapper(Order, s, properties={ + 'user':relation(User, lazy=False) + }) + mapper(User, users) + + q = create_session().query(Order) + self.assert_result(q.list(), Order, + {'order_id':3, 'user' : (User, {'user_id':7})}, + {'order_id':4, 'user' : (User, {'user_id':9})}, + ) + + q = q.select_from(s.outerjoin(orderitems)).filter(orderitems.c.item_name != 'item 2') + self.assert_result(q.list(), Order, + {'order_id':3, 'user' : (User, {'user_id':7})}, + ) + def testmulti(self): """tests eager loading with two relations simultaneously""" |
