Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add not exists support. #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 browser/sql-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@

SUB_SELECT_OP = ['IN', 'NOT IN', 'ANY', 'ALL', 'SOME'];

SUB_SELECT_UNARY_OP = ['EXISTS'];
SUB_SELECT_UNARY_OP = ['EXISTS', 'NOT EXISTS'];

SQL_CONDITIONALS = ['AND', 'OR'];

Expand Down
2 changes: 1 addition & 1 deletion lib/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/lexer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Lexer
SQL_SORT_ORDERS = ['ASC', 'DESC']
SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'IS NOT', 'IS']
SUB_SELECT_OP = ['IN', 'NOT IN', 'ANY', 'ALL', 'SOME']
SUB_SELECT_UNARY_OP = ['EXISTS']
SUB_SELECT_UNARY_OP = ['EXISTS', 'NOT EXISTS']
SQL_CONDITIONALS = ['AND', 'OR']
SQL_BETWEENS = ['BETWEEN', 'NOT BETWEEN']
BOOLEAN = ['TRUE', 'FALSE', 'NULL']
Expand Down
10 changes: 10 additions & 0 deletions test/grammar.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,16 @@ describe "SQL Grammar", ->
))
"""

it "parses an EXISTS clause containing a query", ->
parse("""select * from a where not exists (select foo from bar)""").toString().should.eql """
SELECT *
FROM `a`
WHERE (NOT EXISTS (
SELECT `foo`
FROM `bar`
))
"""

describe "aliases", ->
it "parses aliased table names", ->
parse("""select * from a b""").toString().should.eql """
Expand Down