From 928354dca101e57fcb1c7440a4c2eef45594c5b8 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 23 Mar 2010 20:25:06 -0400 Subject: [PATCH] this one is unbelievable --- test/orm/inheritance/test_query.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/test/orm/inheritance/test_query.py b/test/orm/inheritance/test_query.py index e1118a3f8a..5e6375eab7 100644 --- a/test/orm/inheritance/test_query.py +++ b/test/orm/inheritance/test_query.py @@ -1282,7 +1282,7 @@ class EagerToSubclassTest(_base.MappedTest): ) self.assert_sql_count(testing.db, go, 1) -class SubClassEagerToSubclassTest(_base.MappedTest): +class SubClassEagerToSubClassTest(_base.MappedTest): """Test eagerloads from subclass to subclass mappers""" run_setup_classes = 'once' @@ -1396,4 +1396,27 @@ class SubClassEagerToSubclassTest(_base.MappedTest): ) self.assert_sql_count(testing.db, go, 1) + @testing.resolve_artifact_names + def test_subqueryload(self): + sess = create_session() + def go(): + eq_( + sess.query(Subparent).options(subqueryload(Subparent.children)).all(), + [ + Subparent(data='p1', children=[Sub(data='s1'), Sub(data='s2'), Sub(data='s3')]), + Subparent(data='p2', children=[Sub(data='s4'), Sub(data='s5')]) + ] + ) + self.assert_sql_count(testing.db, go, 2) + + sess.expunge_all() + def go(): + eq_( + sess.query(Subparent).options(subqueryload("children")).all(), + [ + Subparent(data='p1', children=[Sub(data='s1'), Sub(data='s2'), Sub(data='s3')]), + Subparent(data='p2', children=[Sub(data='s4'), Sub(data='s5')]) + ] + ) + self.assert_sql_count(testing.db, go, 2) -- 2.47.3