diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2013-04-20 08:32:08 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2013-04-20 08:32:08 +0200 |
| commit | fd480bf40646cdb53bce377db5d11dc52a760dad (patch) | |
| tree | 59bea5608c5b8c580e9dc426e9a2d79161f99af9 /tests | |
| parent | 90ebf68e551805a30cf7c9907f04f7038e941b5a (diff) | |
| download | sqlparse-fd480bf40646cdb53bce377db5d11dc52a760dad.tar.gz | |
Allow NULL keyword in assignments (fixes #90).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_grouping.py | 14 | ||||
| -rw-r--r-- | tests/test_regressions.py | 20 |
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 674982f..b22e543 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -242,3 +242,17 @@ def test_identifier_consumes_ordering(): # issue89 assert ids[0].get_ordering() == 'DESC' assert ids[1].get_name() == 'c2' assert ids[1].get_ordering() is None + + +def test_comparison_with_keywords(): # issue90 + # in fact these are assignments, but for now we don't distinguish them + p = sqlparse.parse('foo = NULL')[0] + assert len(p.tokens) == 1 + assert isinstance(p.tokens[0], sql.Comparison) + assert len(p.tokens[0].tokens) == 5 + assert p.tokens[0].tokens[0].value == 'foo' + assert p.tokens[0].tokens[-1].value == 'NULL' + # make sure it's case-insensitive + p = sqlparse.parse('foo = null')[0] + assert len(p.tokens) == 1 + assert isinstance(p.tokens[0], sql.Comparison) diff --git a/tests/test_regressions.py b/tests/test_regressions.py index e9d890b..423f2d6 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -198,3 +198,23 @@ def test_format_accepts_encoding(): # issue20 else: tformatted = 'insert into foo\nvalues (1); -- Песня про надежду\n' assert formatted == tformatted + + +def test_issue90(): + sql = ('UPDATE "gallery_photo" SET "owner_id" = 4018, "deleted_at" = NULL,' + ' "width" = NULL, "height" = NULL, "rating_votes" = 0,' + ' "rating_score" = 0, "thumbnail_width" = NULL,' + ' "thumbnail_height" = NULL, "price" = 1, "description" = NULL') + formatted = sqlparse.format(sql, reindent=True) + tformatted = '\n'.join(['UPDATE "gallery_photo"', + 'SET "owner_id" = 4018,', + ' "deleted_at" = NULL,', + ' "width" = NULL,', + ' "height" = NULL,', + ' "rating_votes" = 0,', + ' "rating_score" = 0,', + ' "thumbnail_width" = NULL,', + ' "thumbnail_height" = NULL,', + ' "price" = 1,', + ' "description" = NULL']) + assert formatted == tformatted |
