MCPcopy Create free account
hub / github.com/zzzeek/sqlalchemy / test_join_lateral_w_select_subquery

Method test_join_lateral_w_select_subquery

test/sql/test_lateral.py:217–238  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

215 )
216
217 def test_join_lateral_w_select_subquery(self):
218 table1 = self.tables.people
219 table2 = self.tables.books
220
221 subq = (
222 select(table2.c.book_id)
223 .correlate(table1)
224 .where(table1.c.people_id == table2.c.book_owner_id)
225 .subquery()
226 .lateral()
227 )
228 stmt = select(table1, subq.c.book_id).select_from(
229 table1.join(subq, true())
230 )
231
232 self.assert_compile(
233 stmt,
234 "SELECT people.people_id, people.age, people.name, anon_1.book_id "
235 "FROM people JOIN LATERAL (SELECT books.book_id AS book_id "
236 "FROM books "
237 "WHERE people.people_id = books.book_owner_id) AS anon_1 ON true",
238 )
239
240 @testing.combinations((True,), (False,))
241 def test_join_lateral_subquery_twolevel(self, use_twolevel):

Callers

nothing calls this directly

Calls 9

selectFunction · 0.90
trueFunction · 0.90
assert_compileMethod · 0.80
lateralMethod · 0.45
subqueryMethod · 0.45
whereMethod · 0.45
correlateMethod · 0.45
select_fromMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected