Search in sources :

Example 1 with ComparisonExpression

use of io.crate.sql.tree.ComparisonExpression in project crate by crate.

the class TestStatementBuilder method testCaseSensitivity.

@Test
public void testCaseSensitivity() {
    Expression expression = SqlParser.createExpression("\"firstName\" = 'myName'");
    QualifiedNameReference nameRef = (QualifiedNameReference) ((ComparisonExpression) expression).getLeft();
    StringLiteral myName = (StringLiteral) ((ComparisonExpression) expression).getRight();
    assertThat(nameRef.getName().getSuffix(), is("firstName"));
    assertThat(myName.getValue(), is("myName"));
    expression = SqlParser.createExpression("FIRSTNAME = 'myName'");
    nameRef = (QualifiedNameReference) ((ComparisonExpression) expression).getLeft();
    assertThat(nameRef.getName().getSuffix(), is("firstname"));
    expression = SqlParser.createExpression("ABS(1)");
    QualifiedName functionName = ((FunctionCall) expression).getName();
    assertThat(functionName.getSuffix(), is("abs"));
}
Also used : ArrayComparisonExpression(io.crate.sql.tree.ArrayComparisonExpression) ComparisonExpression(io.crate.sql.tree.ComparisonExpression) EscapedCharStringLiteral(io.crate.sql.tree.EscapedCharStringLiteral) StringLiteral(io.crate.sql.tree.StringLiteral) SubqueryExpression(io.crate.sql.tree.SubqueryExpression) SubscriptExpression(io.crate.sql.tree.SubscriptExpression) ParameterExpression(io.crate.sql.tree.ParameterExpression) ArrayComparisonExpression(io.crate.sql.tree.ArrayComparisonExpression) Expression(io.crate.sql.tree.Expression) ComparisonExpression(io.crate.sql.tree.ComparisonExpression) NegativeExpression(io.crate.sql.tree.NegativeExpression) QualifiedName(io.crate.sql.tree.QualifiedName) FunctionCall(io.crate.sql.tree.FunctionCall) QualifiedNameReference(io.crate.sql.tree.QualifiedNameReference) Test(org.junit.Test)

Aggregations

ArrayComparisonExpression (io.crate.sql.tree.ArrayComparisonExpression)1 ComparisonExpression (io.crate.sql.tree.ComparisonExpression)1 EscapedCharStringLiteral (io.crate.sql.tree.EscapedCharStringLiteral)1 Expression (io.crate.sql.tree.Expression)1 FunctionCall (io.crate.sql.tree.FunctionCall)1 NegativeExpression (io.crate.sql.tree.NegativeExpression)1 ParameterExpression (io.crate.sql.tree.ParameterExpression)1 QualifiedName (io.crate.sql.tree.QualifiedName)1 QualifiedNameReference (io.crate.sql.tree.QualifiedNameReference)1 StringLiteral (io.crate.sql.tree.StringLiteral)1 SubqueryExpression (io.crate.sql.tree.SubqueryExpression)1 SubscriptExpression (io.crate.sql.tree.SubscriptExpression)1 Test (org.junit.Test)1