From a301b79c042c5c4e8677ad6e44905903ea9375c3 Mon Sep 17 00:00:00 2001 From: Likai Liu Date: Tue, 7 Jan 2020 18:22:32 -0500 Subject: [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. --- sqlparse/engine/grouping.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sqlparse/engine') diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index b634128..daaffb0 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -164,7 +164,7 @@ def group_as(tlist): return token.normalized == 'NULL' or not token.is_keyword def valid_next(token): - ttypes = T.DML, T.DDL + ttypes = T.DML, T.DDL, T.CTE return not imt(token, t=ttypes) and token is not None def post(tlist, pidx, tidx, nidx): -- cgit v1.2.1