MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_query_three

Method test_query_three

test/ext/test_serializer.py:207–222  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

205 eq_(list(q2.with_entities(User.id, User.name)), [(9, "fred")])
206
207 def test_query_three(self):
208 ua = aliased(User)
209 q = (
210 Session.query(ua)
211 .join(ua.addresses)
212 .filter(Address.email.like("%fred%"))
213 )
214 for prot in pickle_protocols():
215 q2 = serializer.loads(
216 serializer.dumps(q, prot), users.metadata, Session
217 )
218 eq_(q2.all(), [User(name="fred")])
219
220 # try to pull out the aliased entity here...
221 ua_2 = q2._compile_state()._entities[0].entity_zero.entity
222 eq_(list(q2.with_entities(ua_2.id, ua_2.name)), [(9, "fred")])
223
224 def test_annotated_one(self):
225 j = join(users, addresses)._annotate({"foo": "bar"})

Callers

nothing calls this directly

Calls 13

aliasedFunction · 0.90
eq_Function · 0.90
pickle_protocolsFunction · 0.85
_compile_stateMethod · 0.80
with_entitiesMethod · 0.80
UserClass · 0.70
filterMethod · 0.45
joinMethod · 0.45
queryMethod · 0.45
likeMethod · 0.45
loadsMethod · 0.45
dumpsMethod · 0.45

Tested by

no test coverage detected