liutwv opened a new issue #2831: SQL where include (, report "Missing right paren." URL: https://github.com/apache/incubator-shardingsphere/issues/2831 ## Bug Report ### Which version of ShardingSphere did you use? 4.0.0-RC1 ### Which project did you use? Sharding-JDBC or Sharding-Proxy? Sharding-JDBC ### Expected behavior where my application run sql like this: select * from tb_xxx where xxx = ? and (xxx = ? and xxx = ?) whatever the table tb_xxx using sharing or not the sql is no problem. where I don't use sharding-jdbc, the sql runs fine. ### Actual behavior when I use sharding-jdbc, the sql can't run successful. the error message is : Caused by: java.lang.IllegalStateException: Missing right paren. at com.google.common.base.Preconditions.checkState(Preconditions.java:459) at org.apache.shardingsphere.core.parse.antlr.extractor.impl.dml.PredicateExtractor.extractConditionForParen(PredicateExtractor.java:108) at org.apache.shardingsphere.core.parse.antlr.extractor.impl.dml.PredicateExtractor.extractConditionInternal(PredicateExtractor.java:79) at org.apache.shardingsphere.core.parse.antlr.extractor.impl.dml.PredicateExtractor.extractConditionInternal(PredicateExtractor.java:73) at org.apache.shardingsphere.core.parse.antlr.extractor.impl.dml.PredicateExtractor.extract(PredicateExtractor.java:60) ### Reason analyze (If you can) PredicateExtractor.java: private Optional<OrConditionSegment> extractConditionForParen(Map<ParserRuleContext, Integer> placeholderIndexes, ParserRuleContext exprNode) { int index = -1; for(int i = 0; i < exprNode.getChildCount(); ++i) { if (Paren.isLeftParen(exprNode.getChild(i).getText())) { index = i; break; } } if (-1 != index) { Preconditions.checkState(Paren.match(exprNode.getChild(index).getText(), exprNode.getChild(index + 2).getText()), "Missing right paren."); return RuleName.EXPR.getName().equals(exprNode.getChild(index + 1).getClass().getSimpleName()) ? this.extractConditionInternal(placeholderIndexes, (ParserRuleContext)exprNode.getChild(index + 1)) : Optional.absent(); } else { Optional<ConditionSegment> condition = this.buildCondition(placeholderIndexes, exprNode); if (!condition.isPresent()) { return Optional.absent(); } else { OrConditionSegment result = new OrConditionSegment(); AndConditionSegment newAndCondition = new AndConditionSegment(); newAndCondition.getConditions().add(condition.get()); result.getAndConditions().add(newAndCondition); return Optional.of(result); } } }
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services