MCPcopy Index your code
hub / github.com/dbcli/pgcli / test_multiple_cte_extraction

Function test_multiple_cte_extraction

tests/parseutils/test_ctes.py:105–137  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

103
104
105def test_multiple_cte_extraction():
106 sql = """WITH
107 x AS (SELECT abc, def FROM x),
108 y AS (SELECT ghi, jkl FROM y)
109 SELECT * FROM a, b"""
110
111 start1 = len(
112 """WITH
113 x AS """
114 )
115
116 stop1 = len(
117 """WITH
118 x AS (SELECT abc, def FROM x)"""
119 )
120
121 start2 = len(
122 """WITH
123 x AS (SELECT abc, def FROM x),
124 y AS """
125 )
126
127 stop2 = len(
128 """WITH
129 x AS (SELECT abc, def FROM x),
130 y AS (SELECT ghi, jkl FROM y)"""
131 )
132
133 ctes, remainder = extract_ctes(sql)
134 assert tuple(ctes) == (
135 ("x", ("abc", "def"), start1, stop1),
136 ("y", ("ghi", "jkl"), start2, stop2),
137 )

Callers

nothing calls this directly

Calls 1

extract_ctesFunction · 0.90

Tested by

no test coverage detected