Skip to content

Commit c579650

Browse files
authored
Add ILIKE operator (#1033)
1 parent 7d48dfe commit c579650

7 files changed

Lines changed: 4973 additions & 4792 deletions

File tree

engine/src/main/grammar/SQLGrammar.jjt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ TOKEN :
531531
| < NOT: ("N"|"n")("O"|"o")("T"|"t") >
532532
| < IN: ("I"|"i")("N"|"n") >
533533
| < LIKE: ("L"|"l")("I"|"i")("K"|"k")("E"|"e") >
534+
| < ILIKE: ("I"|"i")("L"|"l")("I"|"i")("K"|"k")("E"|"e") >
534535
| < IS: "is"|"IS"|"Is"|"iS" >
535536
| < BETWEEN: ("B"|"b")("E"|"e")("T"|"t")("W"|"w")("E"|"e")("E"|"e")("N"|"n")>
536537
| < CONTAINS: ("C"|"c")("O"|"o")("N"|"n")("T"|"t")("A"|"a")("I"|"i")("N"|"n")("S"|"s") >
@@ -2497,6 +2498,7 @@ BinaryCompareOperator CompareOperator():
24972498
| result = GeOperator()
24982499
| result = LeOperator()
24992500
| result = LikeOperator()
2501+
| result = ILikeOperator()
25002502
| result = ContainsKeyOperator()
25012503
| result = NearOperator()
25022504
| result = WithinOperator()
@@ -2547,6 +2549,12 @@ LikeOperator LikeOperator():
25472549
<LIKE> {return jjtThis;}
25482550
}
25492551

2552+
ILikeOperator ILikeOperator():
2553+
{}
2554+
{
2555+
<ILIKE> {return jjtThis;}
2556+
}
2557+
25502558
NearOperator NearOperator():
25512559
{}
25522560
{
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright © 2021-present Arcade Data Ltd (info@arcadedata.com)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-FileCopyrightText: 2021-present Arcade Data Ltd (info@arcadedata.com)
17+
* SPDX-License-Identifier: Apache-2.0
18+
*/
19+
/* Generated By:JJTree: Do not edit this line. OLikeOperator.java Version 4.3 */
20+
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_USERTYPE_VISIBILITY_PUBLIC=true */
21+
package com.arcadedb.query.sql.parser;
22+
23+
import com.arcadedb.database.DatabaseInternal;
24+
import com.arcadedb.query.sql.executor.MultiValue;
25+
import com.arcadedb.query.sql.executor.QueryHelper;
26+
27+
public class ILikeOperator extends SimpleNode implements BinaryCompareOperator {
28+
public ILikeOperator(final int id) {
29+
super(id);
30+
}
31+
32+
@Override
33+
public boolean execute(final DatabaseInternal database, final Object iLeft, final Object iRight) {
34+
if (MultiValue.isMultiValue(iLeft) || MultiValue.isMultiValue(iRight))
35+
return false;
36+
37+
if (iLeft == null || iRight == null) {
38+
return false;
39+
}
40+
return QueryHelper.like(iLeft.toString().toLowerCase(), iRight.toString().toLowerCase());
41+
}
42+
43+
@Override
44+
public String toString() {
45+
return "ILIKE";
46+
}
47+
48+
@Override
49+
public ILikeOperator copy() {
50+
return this;
51+
}
52+
53+
@Override
54+
public boolean equals(final Object obj) {
55+
return obj != null && obj.getClass().equals(this.getClass());
56+
}
57+
58+
@Override
59+
public int hashCode() {
60+
return getClass().hashCode();
61+
}
62+
}
63+
/* JavaCC - OriginalChecksum=16d302abf0f85b404e57b964606952ca (do not edit this line) */

0 commit comments

Comments
 (0)