File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
main/java/org/nlpcn/es4sql/parse
test/java/org/nlpcn/es4sql Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -83,13 +83,13 @@ private Where findWhere(SQLExpr where) throws SqlParseException {
83
83
private boolean isCond (SQLBinaryOpExpr expr ) {
84
84
SQLExpr leftSide = expr .getLeft ();
85
85
if (leftSide instanceof SQLMethodInvokeExpr ){
86
- return isAllowedMethodOnConditionLeft ((SQLMethodInvokeExpr ) leftSide );
86
+ return isAllowedMethodOnConditionLeft ((SQLMethodInvokeExpr ) leftSide , expr . getOperator () );
87
87
}
88
88
return leftSide instanceof SQLIdentifierExpr || leftSide instanceof SQLPropertyExpr || leftSide instanceof SQLVariantRefExpr ;
89
89
}
90
90
91
- private boolean isAllowedMethodOnConditionLeft (SQLMethodInvokeExpr method ) {
92
- return method .getMethodName ().toLowerCase ().equals ("nested" );
91
+ private boolean isAllowedMethodOnConditionLeft (SQLMethodInvokeExpr method , SQLBinaryOperator operator ) {
92
+ return method .getMethodName ().toLowerCase ().equals ("nested" ) && ! operator . isLogical () ;
93
93
}
94
94
95
95
public void parseWhere (SQLExpr expr , Where where ) throws SqlParseException {
Original file line number Diff line number Diff line change @@ -771,6 +771,17 @@ public void fieldsAsNumbersOnWhere() throws SqlParseException {
771
771
Assert .assertEquals ("3" , condition .getName ());
772
772
}
773
773
774
+
775
+ @ Test
776
+ public void complexNestedAndOtherQuery () throws SqlParseException {
777
+ String query = "select * from x where nested('path',path.x=3) and y=3" ;
778
+ Select select = parser .parseSelect ((SQLQueryExpr ) queryToExpr (query ));
779
+ LinkedList <Where > wheres = select .getWhere ().getWheres ();
780
+ Assert .assertEquals (2 , wheres .size ());
781
+ Assert .assertEquals ("AND path NESTED_COMPLEX AND ( AND path.x EQ 3 ) " ,wheres .get (0 ).toString ());
782
+ Assert .assertEquals ("AND y EQ 3" ,wheres .get (1 ).toString ());
783
+ }
784
+
774
785
private SQLExpr queryToExpr (String query ) {
775
786
return new ElasticSqlExprParser (query ).expr ();
776
787
}
You can’t perform that action at this time.
0 commit comments