MCPcopy Index your code
hub / github.com/sqlalchemy/sqlalchemy / test_textual_select_stack_correction

Method test_textual_select_stack_correction

test/sql/test_cte.py:1863–1882  ·  view source on GitHub ↗

test #7798 , regression from #7760

(self)

Source from the content-addressed store, hash-verified

1861 )
1862
1863 def test_textual_select_stack_correction(self):
1864 """test #7798 , regression from #7760"""
1865
1866 foo = table("foo", column("id"))
1867 bar = table("bar", column("id"), column("attr"), column("foo_id"))
1868
1869 s1 = text("SELECT id FROM foo").columns(foo.c.id)
1870 s2 = text(
1871 "SELECT bar.id, bar.attr FROM bar WHERE br.id IN "
1872 "(SELECT id FROM baz)"
1873 ).columns(bar.c.id, bar.c.attr)
1874 s3 = bar.insert().from_select(list(s2.selected_columns), s2)
1875 s4 = s3.add_cte(s1.cte(name="baz"))
1876
1877 self.assert_compile(
1878 s4,
1879 "WITH baz AS (SELECT id FROM foo) INSERT INTO bar (id, attr) "
1880 "SELECT bar.id, bar.attr FROM bar WHERE br.id IN "
1881 "(SELECT id FROM baz)",
1882 )
1883
1884 def test_insert_uses_independent_cte(self):
1885 products = table("products", column("id"), column("price"))

Callers

nothing calls this directly

Calls 9

tableFunction · 0.90
columnFunction · 0.90
textFunction · 0.90
from_selectMethod · 0.80
assert_compileMethod · 0.80
columnsMethod · 0.45
insertMethod · 0.45
add_cteMethod · 0.45
cteMethod · 0.45

Tested by

no test coverage detected