MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_result_map_anon_alias

Method test_result_map_anon_alias

test/sql/test_labels.py:315–364  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

313 )
314
315 def test_result_map_anon_alias(self):
316 table1 = self.table1
317 dialect = self._length_fixture()
318
319 q = (
320 table1.select()
321 .where(table1.c.this_is_the_primarykey_column == 4)
322 .alias()
323 )
324 s = select(q).set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
325
326 self.assert_compile(
327 s,
328 "SELECT "
329 "anon_1.this_is_the_primarykey__2 AS anon_1_this_is_the_prim_1, "
330 "anon_1.this_is_the_data_column AS anon_1_this_is_the_data_3 "
331 "FROM ("
332 "SELECT "
333 "some_large_named_table."
334 "this_is_the_primarykey_column AS this_is_the_primarykey__2, "
335 "some_large_named_table."
336 "this_is_the_data_column AS this_is_the_data_column "
337 "FROM "
338 "some_large_named_table "
339 "WHERE "
340 "some_large_named_table.this_is_the_primarykey_column "
341 "= :this_is_the_primarykey__1"
342 ") "
343 "AS anon_1",
344 dialect=dialect,
345 )
346
347 compiled = s.compile(dialect=dialect)
348 assert set(
349 compiled._create_result_map()["anon_1_this_is_the_data_3"][1]
350 ).issuperset(
351 [
352 "anon_1_this_is_the_data_3",
353 q.corresponding_column(table1.c.this_is_the_data_column),
354 ]
355 )
356
357 assert set(
358 compiled._create_result_map()["anon_1_this_is_the_prim_1"][1]
359 ).issuperset(
360 [
361 "anon_1_this_is_the_prim_1",
362 q.corresponding_column(table1.c.this_is_the_primarykey_column),
363 ]
364 )
365
366 def test_column_bind_labels_1(self):
367 table1 = self.table1

Callers

nothing calls this directly

Calls 11

_length_fixtureMethod · 0.95
selectFunction · 0.90
assert_compileMethod · 0.80
_create_result_mapMethod · 0.80
aliasMethod · 0.45
whereMethod · 0.45
selectMethod · 0.45
set_label_styleMethod · 0.45
compileMethod · 0.45
issupersetMethod · 0.45
corresponding_columnMethod · 0.45

Tested by

no test coverage detected