-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
MEMBER OF
condition as shown at https://dev.mysql.com/doc/ref…
- Loading branch information
1 parent
09a70a4
commit 6e7a78d
Showing
9 changed files
with
142 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/net/sf/jsqlparser/expression/operators/relational/MemberOfExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package net.sf.jsqlparser.expression.operators.relational; | ||
|
||
import net.sf.jsqlparser.expression.Expression; | ||
import net.sf.jsqlparser.expression.ExpressionVisitor; | ||
import net.sf.jsqlparser.parser.ASTNodeAccessImpl; | ||
|
||
public class MemberOfExpression extends ASTNodeAccessImpl implements Expression { | ||
|
||
Expression leftExpression; | ||
Expression rightExpression; | ||
boolean isNot; | ||
|
||
public MemberOfExpression(Expression leftExpression, Expression rightExpression) { | ||
this.leftExpression = leftExpression; | ||
this.rightExpression = rightExpression; | ||
} | ||
|
||
public Expression getLeftExpression() { | ||
return leftExpression; | ||
} | ||
|
||
public MemberOfExpression setLeftExpression(Expression leftExpression) { | ||
this.leftExpression = leftExpression; | ||
return this; | ||
} | ||
|
||
public Expression getRightExpression() { | ||
return rightExpression; | ||
} | ||
|
||
public MemberOfExpression setRightExpression(Expression rightExpression) { | ||
this.rightExpression = rightExpression; | ||
return this; | ||
} | ||
|
||
public boolean isNot() { | ||
return isNot; | ||
} | ||
|
||
public MemberOfExpression setNot(boolean not) { | ||
isNot = not; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return leftExpression + " MEMBER OF " + rightExpression; | ||
} | ||
|
||
@Override | ||
public void accept(ExpressionVisitor expressionVisitor) { | ||
expressionVisitor.visit(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/java/net/sf/jsqlparser/expression/operators/relational/MemberOfExpressionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.sf.jsqlparser.expression.operators.relational; | ||
|
||
import net.sf.jsqlparser.JSQLParserException; | ||
import net.sf.jsqlparser.test.TestUtils; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class MemberOfExpressionTest { | ||
@Test | ||
void testMemberOf() throws JSQLParserException { | ||
String sqlStr = "SELECT 17 MEMBER OF ( cxr_post_id->'$.value' ) "; | ||
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true); | ||
|
||
sqlStr = "SELECT 17 MEMBER OF ( '[23, \"abc\", 17, \"ab\", 10]' ) "; | ||
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true); | ||
} | ||
} |