diff options
| author | Andi Albrecht <andi@lap-pu35.prounix.local> | 2017-03-02 05:37:20 +0100 |
|---|---|---|
| committer | Andi Albrecht <andi@lap-pu35.prounix.local> | 2017-03-02 05:37:20 +0100 |
| commit | 59033cc0ea75e160c87a68de6817cad06888cc38 (patch) | |
| tree | e744c90531788586f2edbeeeb7bdfd1f3843ca55 | |
| parent | 0ea7cf49bd329bba28833a7e33c95b131c71a029 (diff) | |
| download | sqlparse-59033cc0ea75e160c87a68de6817cad06888cc38.tar.gz | |
Fix parsing of INTO keyword in WHERE clauses (fixes #324).
| -rw-r--r-- | CHANGELOG | 1 | ||||
| -rw-r--r-- | sqlparse/sql.py | 2 | ||||
| -rw-r--r-- | tests/test_grouping.py | 8 |
3 files changed, 10 insertions, 1 deletions
@@ -10,6 +10,7 @@ Bug Fixes * Fix some edge-cases when parsing invalid SQL statements. * Fix indentation of LIMIT (by romainr, issue320). +* Fix parsing of INTO keyword (issue324). Internal Changes diff --git a/sqlparse/sql.py b/sqlparse/sql.py index c0f8306..f190de8 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -527,7 +527,7 @@ class Where(TokenList): """A WHERE clause.""" M_OPEN = T.Keyword, 'WHERE' M_CLOSE = T.Keyword, ('ORDER', 'GROUP', 'LIMIT', 'UNION', 'EXCEPT', - 'HAVING', 'RETURNING') + 'HAVING', 'RETURNING', 'INTO') class Case(TokenList): diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 02d211e..72f94f6 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -210,6 +210,14 @@ def test_returning_kw_ends_where_clause(): assert p.tokens[7].value == 'returning' +def test_into_kw_ends_where_clause(): # issue324 + s = 'select * from foo where a = 1 into baz' + p = sqlparse.parse(s)[0] + assert isinstance(p.tokens[8], sql.Where) + assert p.tokens[9].ttype == T.Keyword + assert p.tokens[9].value == 'into' + + @pytest.mark.parametrize('sql, expected', [ # note: typecast needs to be 2nd token for this test ('select foo::integer from bar', 'integer'), |
