Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lexer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Lexer

SQL_FUNCTIONS = ['AVG', 'COUNT', 'MIN', 'MAX', 'SUM']
SQL_SORT_ORDERS = ['ASC', 'DESC']
SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'IS NOT', 'IS']
SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'NOT LIKE', 'IS NOT', 'IS']
SUB_SELECT_OP = ['IN', 'NOT IN', 'ANY', 'ALL', 'SOME']
SUB_SELECT_UNARY_OP = ['EXISTS']
SQL_CONDITIONALS = ['AND', 'OR']
Expand Down
7 changes: 7 additions & 0 deletions test/grammar.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ describe "SQL Grammar", ->
WHERE ((`a` > 10) AND ((`a` < 30) OR (`b` = 'c')))
"""

it "parses WHERE with LIKE and NOT LIKE clauses", ->
parse("SELECT * FROM my_table WHERE foo LIKE '%a' AND bar NOT LIKE 'b%'").toString().should.eql """
SELECT *
FROM `my_table`
WHERE ((`foo` LIKE '%a') AND (`bar` NOT LIKE 'b%'))
"""

it "parses WHERE with ORDER BY clauses", ->
parse("SELECT * FROM my_table WHERE x > 1 ORDER BY y").toString().should.eql """
SELECT *
Expand Down