Skip to content

Commit fba9122

Browse files
authored
Merge pull request #635 from sh-tomer/add_support_for_logical_operators
add support for && operator
2 parents 5b85507 + e4a91cd commit fba9122

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
140140
| <K_ALL:"ALL">
141141
| <K_ALTER:"ALTER">
142142
| <K_AND:"AND">
143+
| <K_AND_OPERATOR:"&&">
143144
| <K_ANY:"ANY">
144145
| <K_AS: "AS">
145146
| <K_ASC:"ASC">
@@ -2015,7 +2016,7 @@ Expression AndExpression() :
20152016
{ result = left; }
20162017

20172018
(
2018-
<K_AND>
2019+
(<K_AND> | <K_AND_OPERATOR>)
20192020
(
20202021
LOOKAHEAD(Condition())
20212022
right=Condition()

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,6 +3182,13 @@ public void testSqlContainIsNullFunctionShouldBeParsed() throws JSQLParserExcept
31823182
public void testNestedCast() throws JSQLParserException {
31833183
assertSqlCanBeParsedAndDeparsed("SELECT acolumn::bit (64)::bigint FROM mytable");
31843184
}
3185+
3186+
@Test
3187+
public void testAndOperator() throws JSQLParserException {
3188+
String stmt = "SELECT name from customers where name = 'John' && lastname = 'Doh'";
3189+
Statement parsed = parserManager.parse(new StringReader(stmt));
3190+
assertStatementCanBeDeparsedAs(parsed, "SELECT name FROM customers WHERE name = 'John' AND lastname = 'Doh'");
3191+
}
31853192

31863193
@Test
31873194
public void testNamedParametersIssue612() throws Exception {

0 commit comments

Comments
 (0)