MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_subqueryload_post_context

Method test_subqueryload_post_context

test/ext/test_baked.py:905–933  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

903 sess.close()
904
905 def test_subqueryload_post_context(self):
906 User = self.classes.User
907 Address = self.classes.Address
908
909 assert_result = [
910 User(
911 id=7, addresses=[Address(id=1, email_address="jack@bean.com")]
912 )
913 ]
914
915 self.bakery = baked.bakery()
916
917 bq = self.bakery(lambda s: s.query(User))
918
919 bq += lambda q: q.options(subqueryload(User.addresses))
920 bq += lambda q: q.order_by(User.id)
921 bq += lambda q: q.filter(User.name == bindparam("name"))
922 sess = fixture_session()
923
924 def set_params(q):
925 return q.params(name="jack")
926
927 # test that the changes we make using with_post_criteria()
928 # are also applied to the subqueryload query.
929 def go():
930 result = bq(sess).with_post_criteria(set_params).all()
931 eq_(assert_result, result)
932
933 self.assert_sql_count(testing.db, go, 2)
934
935 @testing.fixture()
936 def before_compile_nobake_fixture(self):

Callers

nothing calls this directly

Calls 11

subqueryloadFunction · 0.90
bindparamFunction · 0.90
fixture_sessionFunction · 0.90
bakeryMethod · 0.80
assert_sql_countMethod · 0.80
UserClass · 0.70
AddressClass · 0.70
queryMethod · 0.45
optionsMethod · 0.45
order_byMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected