Skip to content

Commit 991ee17

Browse files
committed
Fix #4 Support ILIKE operator
1 parent bb21b4a commit 991ee17

File tree

8 files changed

+18
-10
lines changed

8 files changed

+18
-10
lines changed

Cakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ header = """
88
/*!
99
* SQLParser #{pkg.version}
1010
* Copyright 2012-2015 Andy Kent <andy@forward.co.uk>
11-
* Copyright 2015-2018 Damien "Mistic" Sorel (http://www.strangeplanet.fr)
11+
* Copyright 2015-2018 Damien "Mistic" Sorel (https://www.strangeplanet.fr)
1212
* Licensed under MIT (http://opensource.org/licenses/MIT)
1313
*/
1414
"""

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Copyright (c) 2012 Andrew Kent
2+
Copyright (c) 2016-2018 Damien "Mistic" Sorel
23

34
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
45

browser/sql-parser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
2-
* SQLParser 1.2.0
2+
* SQLParser 1.2.1
33
* Copyright 2012-2015 Andy Kent <andy@forward.co.uk>
4-
* Copyright 2015-2018 Damien "Mistic" Sorel (http://www.strangeplanet.fr)
4+
* Copyright 2015-2018 Damien "Mistic" Sorel (https://www.strangeplanet.fr)
55
* Licensed under MIT (http://opensource.org/licenses/MIT)
66
*/
77
(function(root) {
@@ -238,7 +238,7 @@
238238

239239
SQL_SORT_ORDERS = ['ASC', 'DESC'];
240240

241-
SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'NOT LIKE', 'IS NOT', 'IS', 'REGEXP'];
241+
SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'NOT LIKE', 'ILIKE', 'NOT ILIKE', 'IS', 'IS NOT', 'REGEXP', 'NOT REGEXP'];
242242

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

browser/sql-parser.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/lexer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sql-parser-mistic",
33
"description": "Lexer and Parser for SQL Syntax",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"author": {
66
"name": "Andy Kent",
77
"email": "andy@forward.co.uk"

src/lexer.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Lexer
157157

158158
SQL_FUNCTIONS = ['AVG', 'COUNT', 'MIN', 'MAX', 'SUM']
159159
SQL_SORT_ORDERS = ['ASC', 'DESC']
160-
SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'NOT LIKE', 'IS NOT', 'IS', 'REGEXP', 'NOT REGEXP']
160+
SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'NOT LIKE', 'ILIKE', 'NOT ILIKE', 'IS', 'IS NOT', 'REGEXP', 'NOT REGEXP']
161161
SUB_SELECT_OP = ['IN', 'NOT IN', 'ANY', 'ALL', 'SOME']
162162
SUB_SELECT_UNARY_OP = ['EXISTS']
163163
SQL_CONDITIONALS = ['AND', 'OR']

test/grammar.spec.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ describe "SQL Grammar", ->
148148
WHERE ((`foo` LIKE '%a') AND (`bar` NOT LIKE 'b%'))
149149
"""
150150

151+
it "parses WHERE with ILIKE and NOT ILIKE clauses", ->
152+
parse("SELECT * FROM my_table WHERE foo ILIKE '%a' AND bar NOT ILIKE 'b%'").toString().should.eql """
153+
SELECT *
154+
FROM `my_table`
155+
WHERE ((`foo` ILIKE '%a') AND (`bar` NOT ILIKE 'b%'))
156+
"""
157+
151158
it "parses WHERE with ORDER BY clauses", ->
152159
parse("SELECT * FROM my_table WHERE x > 1 ORDER BY y").toString().should.eql """
153160
SELECT *

0 commit comments

Comments
 (0)