summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFredy Wijaya <fredy.wijaya@gmail.com>2018-12-01 10:57:25 -0600
committerAndi Albrecht <albrecht.andi@gmail.com>2018-12-03 14:15:11 +0100
commit4140d2ea1514b1d293cc4802880c2e414ffc615c (patch)
tree714f7e50fc65d66457d63c7f1b41d7459d847f02 /tests
parentafd05eeeebdd4360224dfeabcd60ed704fd705fa (diff)
downloadsqlparse-4140d2ea1514b1d293cc4802880c2e414ffc615c.tar.gz
Fix from( parsing issue (fixes #446)
Diffstat (limited to 'tests')
-rw-r--r--tests/test_parse.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_parse.py b/tests/test_parse.py
index d191f65..4fad526 100644
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -435,6 +435,24 @@ def test_get_real_name():
assert 't' == stmts[0].get_alias()
+def test_from_subquery():
+ # issue 446
+ s = u'from(select 1)'
+ stmts = sqlparse.parse(s)
+ assert len(stmts) == 1
+ assert len(stmts[0].tokens) == 2
+ assert stmts[0].tokens[0].value == 'from'
+ assert stmts[0].tokens[0].ttype == T.Keyword
+
+ s = u'from (select 1)'
+ stmts = sqlparse.parse(s)
+ assert len(stmts) == 1
+ assert len(stmts[0].tokens) == 3
+ assert stmts[0].tokens[0].value == 'from'
+ assert stmts[0].tokens[0].ttype == T.Keyword
+ assert stmts[0].tokens[1].ttype == T.Whitespace
+
+
def test_parenthesis():
tokens = sqlparse.parse("(\n\n1\n\n)")[0].tokens[0].tokens
assert list(map(lambda t: t.ttype, tokens)) == [T.Punctuation,