diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2014-11-30 06:48:25 +0100 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2014-11-30 06:48:25 +0100 |
| commit | dcd67a6e21c2fb523caa5dc9c41e62fcd4e45319 (patch) | |
| tree | 1d3ad63f7c405a0bf1fbe26128857693afeae528 | |
| parent | 0619bb662fb102eabb78f7059270d5766812c1e1 (diff) | |
| download | sqlparse-dcd67a6e21c2fb523caa5dc9c41e62fcd4e45319.tar.gz | |
Better handling of floats in UPDATE statements (issue145).
| -rw-r--r-- | CHANGES | 1 | ||||
| -rw-r--r-- | sqlparse/engine/grouping.py | 2 | ||||
| -rw-r--r-- | tests/test_grouping.py | 9 |
3 files changed, 11 insertions, 1 deletions
@@ -2,6 +2,7 @@ Development Version ------------------- Bug Fixes +* Floats in UPDATE statements are now handled correctly (issue145). * Properly handle string literals in comparisons (issue148, change proposed by aadis). diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index a63b80c..ee534e3 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -135,7 +135,7 @@ def group_comparison(tlist): def _parts_valid(token): return (token.ttype in (T.String.Symbol, T.String.Single, - T.Name, T.Number, + T.Name, T.Number, T.Number.Float, T.Number.Integer, T.Literal, T.Literal.Number.Integer, T.Name.Placeholder) or isinstance(token, (sql.Identifier, sql.Parenthesis)) diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 93f1b0e..86d4c7a 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -278,6 +278,15 @@ def test_comparison_with_keywords(): # issue90 assert isinstance(p.tokens[0], sql.Comparison) +def test_comparison_with_floats(): # issue145 + p = sqlparse.parse('foo = 25.5')[0] + assert len(p.tokens) == 1 + assert isinstance(p.tokens[0], sql.Comparison) + assert len(p.tokens[0].tokens) == 5 + assert p.tokens[0].left.value == 'foo' + assert p.tokens[0].right.value == '25.5' + + def test_comparison_with_parenthesis(): # issue23 p = sqlparse.parse('(3 + 4) = 7')[0] assert len(p.tokens) == 1 |
