MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_join_with_entities

Method test_join_with_entities

test/orm/test_joins.py:306–339  ·  view source on GitHub ↗

test issue #6503

(self, legacy, threelevel)

Source from the content-addressed store, hash-verified

304 @testing.combinations((True,), (False,), argnames="legacy")
305 @testing.combinations((True,), (False,), argnames="threelevel")
306 def test_join_with_entities(self, legacy, threelevel):
307 """test issue #6503"""
308
309 User, Address, Dingaling = self.classes("User", "Address", "Dingaling")
310
311 if legacy:
312 sess = fixture_session()
313 stmt = sess.query(User).join(Address).with_entities(Address.id)
314 else:
315 stmt = select(User).join(Address).with_only_columns(Address.id)
316
317 stmt = stmt.set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
318
319 if threelevel:
320 if legacy:
321 stmt = stmt.join(Address.dingaling).with_entities(Dingaling.id)
322 else:
323 stmt = stmt.join(Address.dingaling).with_only_columns(
324 Dingaling.id
325 )
326
327 if threelevel:
328 self.assert_compile(
329 stmt,
330 "SELECT dingalings.id AS dingalings_id "
331 "FROM users JOIN addresses ON users.id = addresses.user_id "
332 "JOIN dingalings ON addresses.id = dingalings.address_id",
333 )
334 else:
335 self.assert_compile(
336 stmt,
337 "SELECT addresses.id AS addresses_id FROM users "
338 "JOIN addresses ON users.id = addresses.user_id",
339 )
340
341 @testing.combinations((True,), (False,), argnames="legacy")
342 @testing.combinations((True,), (False,), argnames="threelevel")

Callers

nothing calls this directly

Calls 8

fixture_sessionFunction · 0.90
selectFunction · 0.90
with_entitiesMethod · 0.80
with_only_columnsMethod · 0.80
assert_compileMethod · 0.80
joinMethod · 0.45
queryMethod · 0.45
set_label_styleMethod · 0.45

Tested by

no test coverage detected