diff options
| -rw-r--r-- | CHANGES | 1 | ||||
| -rw-r--r-- | sqlparse/engine/grouping.py | 1 | ||||
| -rw-r--r-- | tests/test_grouping.py | 6 |
3 files changed, 8 insertions, 0 deletions
@@ -4,6 +4,7 @@ Development Bug Fixes * Fix incorrect parsing of string literals containing line breaks (issue118). * Fix typo in keywords, add MERGE keywords (issue122, by Cristian Orellana). +* Improve parsing of string literals in columns. Enhancements * Classify DML keywords (issue116, by Victor Hahn). diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index 29f7a37..44cc124 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -157,6 +157,7 @@ def group_identifier(tlist): lambda y: (y.ttype in (T.String.Symbol, T.Name, T.Wildcard, + T.Literal.String.Single, T.Literal.Number.Integer, T.Literal.Number.Float) or isinstance(y, (sql.Parenthesis, sql.Function))))) diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 24b50dc..38c1f66 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -238,6 +238,12 @@ def test_identifier_with_op_trailing_ws(): assert p.tokens[1].ttype is T.Whitespace +def test_identifier_with_string_literals(): + p = sqlparse.parse('foo + \'bar\'')[0] + assert len(p.tokens) == 1 + assert isinstance(p.tokens[0], sql.Identifier) + + # This test seems to be wrong. It was introduced when fixing #53, but #111 # showed that this shouldn't be an identifier at all. I'm leaving this # commented in the source for a while. |
