diff options
| author | Likai Liu <liulk@likai.org> | 2020-01-07 18:22:32 -0500 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2020-02-02 21:21:09 +0100 |
| commit | a301b79c042c5c4e8677ad6e44905903ea9375c3 (patch) | |
| tree | ca40612759532ba231b57f1388eb446dc71b67fc /tests | |
| parent | 44eacf2e2f4a4255829109a5e67e0c1d2af542da (diff) | |
| download | sqlparse-a301b79c042c5c4e8677ad6e44905903ea9375c3.tar.gz | |
[grouping] group_as() no longer groups AS CTE
This patch changes the grouping of AS so that:
Foo AS WITH bar AS 1 SELECT 2
with no longer be grouped as:
[Identifier[Foo, AS, WITH, Identifier[Bar AS 1]], SELECT, 2]
but will be grouped as:
[Identifier[Foo], AS, WITH, Identifier[Bar AS 1], SELECT, 2]
This fixes the parsing of CREATE TABLE new_table AS WITH ... so the
rest of the tokens after AS are parsed the same as a bare WITH.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_grouping.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 6b5bb68..a147063 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -632,3 +632,11 @@ def test_aliased_literal_without_as(): p = sqlparse.parse('1 foo')[0].tokens assert len(p) == 1 assert p[0].get_alias() == 'foo' + + +def test_grouping_as_cte(): + p = sqlparse.parse('foo AS WITH apple AS 1, banana AS 2')[0].tokens + assert len(p) > 4 + assert p[0].get_alias() is None + assert p[2].value == 'AS' + assert p[4].value == 'WITH' |
