summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDarik Gamble <darik.gamble@gmail.com>2015-05-01 19:03:20 -0400
committerDarik Gamble <darik.gamble@gmail.com>2015-05-02 17:33:23 -0400
commitff9caf45f443194635d30b898d18c6a03bcb1a89 (patch)
treebd416aab0cfcce6d3c39e0a8e06c34c5ba54017d /tests
parentf0dcb3870881b1d6f76f67cc871fd6986c8684eb (diff)
improve find_prev_keywords
1) Add clarifying comments 2) Fix bug where a keyword inside of a TokenList would result in a ValueError 3) Ignore as keywords a fixed list of logical operators
Diffstat (limited to 'tests')
-rw-r--r--tests/test_parseutils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_parseutils.py b/tests/test_parseutils.py
index a93e1190..8182b3e3 100644
--- a/tests/test_parseutils.py
+++ b/tests/test_parseutils.py
@@ -88,3 +88,12 @@ def test_find_prev_keyword_using():
q = 'select * from tbl1 inner join tbl2 using (col1, '
kw, q2 = find_prev_keyword(q)
assert kw == '(' and q2 == 'select * from tbl1 inner join tbl2 using ('
+
+@pytest.mark.parametrize('sql', [
+ 'select * from foo where bar',
+ 'select * from foo where bar = 1 and baz or ',
+ 'select * from foo where bar = 1 and baz between qux and ',
+])
+def test_find_prev_keyword_where(sql):
+ kw, stripped = find_prev_keyword(sql)
+ assert kw == 'where' and stripped == 'select * from foo where'