diff options
| author | Andreas Albrecht <a.albrecht@Mac-PU08.prounix.local> | 2019-10-09 11:14:27 +0200 |
|---|---|---|
| committer | Andreas Albrecht <a.albrecht@Mac-PU08.prounix.local> | 2019-10-09 11:14:27 +0200 |
| commit | e8ae45d9f0e4238add9e24af2b8cfbc1665aab77 (patch) | |
| tree | 451cba08a3ac2f9e7c8e56abc3133acb33a13538 /tests | |
| parent | 91cfc1bfcd86640538fa98b6ceaae64d0d4c9328 (diff) | |
| download | sqlparse-e8ae45d9f0e4238add9e24af2b8cfbc1665aab77.tar.gz | |
Restrict detection of alias names (fixes #455).
This change adopts some parts of the pull request #509 by
john-bodley. Thanks!
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_grouping.py | 7 | ||||
| -rw-r--r-- | tests/test_parse.py | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 63a01f2..c2d8860 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -294,9 +294,10 @@ def test_grouping_subquery_no_parens(): assert isinstance(p.tokens[0], sql.Case) -def test_grouping_alias_returns_none(): - # see issue185 - p = sqlparse.parse('foo.bar')[0] +@pytest.mark.parametrize('s', ['foo.bar', 'x, y', 'x > y', 'x / y']) +def test_grouping_alias_returns_none(s): + # see issue185 and issue445 + p = sqlparse.parse(s)[0] assert len(p.tokens) == 1 assert p.tokens[0].get_alias() is None diff --git a/tests/test_parse.py b/tests/test_parse.py index f2a2bda..c28cb06 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -431,8 +431,8 @@ def test_get_real_name(): s = u"update a t set t.b=1" stmts = sqlparse.parse(s) assert len(stmts) == 1 - assert 'a' == stmts[0].get_real_name() - assert 't' == stmts[0].get_alias() + assert 'a' == stmts[0].tokens[2].get_real_name() + assert 't' == stmts[0].tokens[2].get_alias() def test_from_subquery(): |
