Skip to content

Commit

Permalink
TEIID-5005 expanding the use of nesting parens
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Jul 25, 2017
1 parent f853ea8 commit 129a173
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Expand Up @@ -168,7 +168,7 @@ public void visit(AggregateFunction obj) {
}

public void visit(Comparison obj) {
if (obj.getLeftExpression() instanceof Comparison) {
if (obj.getLeftExpression() instanceof Condition) {
buffer.append(Tokens.LPAREN);
append(obj.getLeftExpression());
buffer.append(Tokens.RPAREN);
Expand All @@ -178,7 +178,7 @@ public void visit(Comparison obj) {
buffer.append(Tokens.SPACE);
buffer.append(obj.getOperator());
buffer.append(Tokens.SPACE);
if (obj.getRightExpression() instanceof Comparison) {
if (obj.getRightExpression() instanceof Condition) {
buffer.append(Tokens.LPAREN);
appendRightComparison(obj);
buffer.append(Tokens.RPAREN);
Expand Down
Expand Up @@ -649,6 +649,10 @@ public void helpTestVisitor(String vdb, String input, String expectedOutput) thr
helpTestVisitor(TranslationHelper.BQT_VDB,
"SELECT intkey from bqt1.smalla where (intkey < 10) = true", //$NON-NLS-1$
"SELECT SmallA.IntKey FROM SmallA WHERE (SmallA.IntKey < 10) = TRUE"); //$NON-NLS-1$

helpTestVisitor(TranslationHelper.BQT_VDB,
"select SmallA.StringKey from BQT1.SmallA where ((BooleanValue=true) and (IntKey=1)) = true", //$NON-NLS-1$
"SELECT SmallA.StringKey FROM SmallA WHERE (SmallA.BooleanValue = TRUE AND SmallA.IntKey = 1) = TRUE"); //$NON-NLS-1$
}

}
Expand Up @@ -186,7 +186,7 @@ public void visit( CaseExpression obj ) {
@Override
public void visit( CompareCriteria obj ) {
Expression leftExpression = obj.getLeftExpression();
if (leftExpression instanceof CompareCriteria) {
if (leftExpression instanceof Criteria) {
append(Tokens.LPAREN);
visitNode(leftExpression);
append(Tokens.RPAREN);
Expand All @@ -197,7 +197,7 @@ public void visit( CompareCriteria obj ) {
append(obj.getOperatorAsString());
append(SPACE);
Expression rightExpression = obj.getRightExpression();
if (rightExpression instanceof CompareCriteria) {
if (rightExpression instanceof Criteria) {
append(Tokens.LPAREN);
visitNode(rightExpression);
append(Tokens.RPAREN);
Expand Down
Expand Up @@ -1784,6 +1784,13 @@ public Expression helpTestExpression(String sql, String expected) throws QueryPa
new Constant(false) ); //$NON-NLS-1$

helpTest(cc1, "(m.g.c1 = 'abc') = FALSE"); //$NON-NLS-1$

cc1.setLeftExpression(new CompoundCriteria(Arrays.asList(cc, new CompareCriteria(
new ElementSymbol("m.g.c2"), //$NON-NLS-1$
CompareCriteria.GT,
new Constant(1)))));

helpTest(cc1, "((m.g.c1 = 'abc') AND (m.g.c2 > 1)) = FALSE"); //$NON-NLS-1$
}

}

0 comments on commit 129a173

Please sign in to comment.