Skip to content

Commit

Permalink
Fix #4 Support ILIKE operator
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Apr 2, 2018
1 parent bb21b4a commit 991ee17
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cakefile
Expand Up @@ -8,7 +8,7 @@ header = """
/*!
* SQLParser #{pkg.version}
* Copyright 2012-2015 Andy Kent <andy@forward.co.uk>
* Copyright 2015-2018 Damien "Mistic" Sorel (http://www.strangeplanet.fr)
* Copyright 2015-2018 Damien "Mistic" Sorel (https://www.strangeplanet.fr)
* Licensed under MIT (http://opensource.org/licenses/MIT)
*/
"""
Expand Down
1 change: 1 addition & 0 deletions LICENSE
@@ -1,4 +1,5 @@
Copyright (c) 2012 Andrew Kent
Copyright (c) 2016-2018 Damien "Mistic" Sorel

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:

Expand Down
6 changes: 3 additions & 3 deletions browser/sql-parser.js
@@ -1,7 +1,7 @@
/*!
* SQLParser 1.2.0
* SQLParser 1.2.1
* Copyright 2012-2015 Andy Kent <andy@forward.co.uk>
* Copyright 2015-2018 Damien "Mistic" Sorel (http://www.strangeplanet.fr)
* Copyright 2015-2018 Damien "Mistic" Sorel (https://www.strangeplanet.fr)
* Licensed under MIT (http://opensource.org/licenses/MIT)
*/
(function(root) {
Expand Down Expand Up @@ -238,7 +238,7 @@

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

SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'NOT LIKE', 'IS NOT', 'IS', 'REGEXP'];
SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'NOT LIKE', 'ILIKE', 'NOT ILIKE', 'IS', 'IS NOT', 'REGEXP', 'NOT REGEXP'];

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

Expand Down
6 changes: 3 additions & 3 deletions browser/sql-parser.min.js

Large diffs are not rendered by default.

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 package.json
@@ -1,7 +1,7 @@
{
"name": "sql-parser-mistic",
"description": "Lexer and Parser for SQL Syntax",
"version": "1.2.0",
"version": "1.2.1",
"author": {
"name": "Andy Kent",
"email": "andy@forward.co.uk"
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.coffee
Expand Up @@ -157,7 +157,7 @@ class Lexer

SQL_FUNCTIONS = ['AVG', 'COUNT', 'MIN', 'MAX', 'SUM']
SQL_SORT_ORDERS = ['ASC', 'DESC']
SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'NOT LIKE', 'IS NOT', 'IS', 'REGEXP', 'NOT REGEXP']
SQL_OPERATORS = ['=', '!=', '>=', '>', '<=', '<>', '<', 'LIKE', 'NOT LIKE', 'ILIKE', 'NOT ILIKE', 'IS', 'IS NOT', 'REGEXP', 'NOT REGEXP']
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
Expand Up @@ -148,6 +148,13 @@ describe "SQL Grammar", ->
WHERE ((`foo` LIKE '%a') AND (`bar` NOT LIKE 'b%'))
"""

it "parses WHERE with ILIKE and NOT ILIKE clauses", ->
parse("SELECT * FROM my_table WHERE foo ILIKE '%a' AND bar NOT ILIKE 'b%'").toString().should.eql """
SELECT *
FROM `my_table`
WHERE ((`foo` ILIKE '%a') AND (`bar` NOT ILIKE '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

0 comments on commit 991ee17

Please sign in to comment.