MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_withjoinedload

Method test_withjoinedload

test/orm/test_assorted_eager.py:247–283  ·  view source on GitHub ↗

Test that an joinedload locates the correct "from" clause with which to attach to, when presented with a query that already has a complicated from clause.

(self)

Source from the content-addressed store, hash-verified

245 eq_(result_str, ["1 Some Category", "3 Some Category"])
246
247 def test_withjoinedload(self):
248 """
249 Test that an joinedload locates the correct "from" clause with which to
250 attach to, when presented with a query that already has a complicated
251 from clause.
252
253 """
254
255 Thing, tests, options = (
256 self.classes.Thing,
257 self.tables.tests,
258 self.tables.options,
259 )
260
261 s = fixture_session()
262 q = s.query(Thing).options(sa.orm.joinedload(Thing.category))
263
264 result = q.select_from(
265 tests.outerjoin(
266 options,
267 sa.and_(
268 tests.c.id == options.c.test_id,
269 tests.c.owner_id == options.c.owner_id,
270 ),
271 )
272 ).filter(
273 sa.and_(
274 tests.c.owner_id == 1,
275 sa.or_(
276 options.c.someoption == None,
277 options.c.someoption == False, # noqa
278 ),
279 )
280 )
281
282 result_str = ["%d %s" % (t.id, t.category.name) for t in result]
283 eq_(result_str, ["1 Some Category", "3 Some Category"])
284
285 def test_dslish(self):
286 """test the same as withjoinedload except using generative"""

Callers

nothing calls this directly

Calls 10

fixture_sessionFunction · 0.90
eq_Function · 0.90
joinedloadMethod · 0.80
or_Method · 0.80
optionsMethod · 0.45
queryMethod · 0.45
filterMethod · 0.45
select_fromMethod · 0.45
outerjoinMethod · 0.45
and_Method · 0.45

Tested by

no test coverage detected