Skip to content

Commit ec0dc88

Browse files
committed
Added support for MySQL REGEXP BINARY (for case insensitivity)
1 parent 4d9e461 commit ec0dc88

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
195195
| <K_CURRENT: "CURRENT">
196196
| <K_ROW: "ROW">
197197
| <K_RETURNING: "RETURNING">
198-
| <K_REGEXP: "REGEXP">
199-
198+
| <K_REGEXP_B: "REGEXP BINARY">
199+
| <K_REGEXP: "REGEXP">
200200
}
201201

202202
TOKEN : /* Numeric Constants */
@@ -1281,6 +1281,7 @@ Expression RegularCondition():
12811281
| "@@" { result = new Matches(); }
12821282
| "~" { result = new RegExpMatchOperator(RegExpMatchOperatorType.MATCH_CASESENSITIVE); }
12831283
| <K_REGEXP> { result = new RegExpMySQLOperator(RegExpMatchOperatorType.MATCH_CASEINSENSITIVE); }
1284+
| <K_REGEXP_B> { result = new RegExpMySQLOperator(RegExpMatchOperatorType.MATCH_CASESENSITIVE); }
12841285
| "~*" { result = new RegExpMatchOperator(RegExpMatchOperatorType.MATCH_CASEINSENSITIVE); }
12851286
| "!~" { result = new RegExpMatchOperator(RegExpMatchOperatorType.NOT_MATCH_CASESENSITIVE); }
12861287
| "!~*" { result = new RegExpMatchOperator(RegExpMatchOperatorType.NOT_MATCH_CASEINSENSITIVE); }

src/test/java/net/sf/jsqlparser/test/select/SelectTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,11 @@ public void testRegexpMySQL() throws JSQLParserException {
13301330
String stmt = "SELECT * FROM mytable WHERE first_name REGEXP '^Ste(v|ph)en$'";
13311331
assertSqlCanBeParsedAndDeparsed(stmt);
13321332
}
1333+
1334+
public void testRegexpBinaryMySQL() throws JSQLParserException {
1335+
String stmt = "SELECT * FROM mytable WHERE first_name REGEXP BINARY '^Ste(v|ph)en$'";
1336+
assertSqlCanBeParsedAndDeparsed(stmt);
1337+
}
13331338

13341339
public void testBooleanFunction1() throws JSQLParserException {
13351340
String stmt = "SELECT * FROM mytable WHERE test_func(col1)";

0 commit comments

Comments
 (0)