summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAki Ariga <chezou+github@gmail.com>2022-05-03 00:33:01 -0700
committerAndi Albrecht <albrecht.andi@gmail.com>2022-08-24 21:08:17 +0200
commit7de1999a0af9dbbd09f0afb3a50383ad91c22c4c (patch)
tree631532bb4b3d5d2af10260bdfaac17a16e03d7de /tests
parent4862d68ef15617266c8cc8174beb705fb388ec20 (diff)
downloadsqlparse-7de1999a0af9dbbd09f0afb3a50383ad91c22c4c.tar.gz
CREATE TABLE tbl AS SELECT should return get_alias() for its column
Diffstat (limited to 'tests')
-rw-r--r--tests/test_grouping.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/test_grouping.py b/tests/test_grouping.py
index cf629e9..8c034f9 100644
--- a/tests/test_grouping.py
+++ b/tests/test_grouping.py
@@ -324,6 +324,11 @@ def test_grouping_alias_case():
assert p.tokens[0].get_alias() == 'foo'
+def test_grouping_alias_ctas():
+ p = sqlparse.parse('CREATE TABLE tbl1 AS SELECT coalesce(t1.col1, 0) AS col1 FROM t1')[0]
+ assert p.tokens[10].get_alias() == 'col1'
+ assert isinstance(p.tokens[10].tokens[0], sql.Function)
+
def test_grouping_subquery_no_parens():
# Not totally sure if this is the right approach...
# When a THEN clause contains a subquery w/o parenthesis around it *and*