Search in sources :

Example 1 with Like

use of org.teiid.language.Like in project teiid by teiid.

the class TestLikeCriteriaImpl method testGetRightExpression.

public void testGetRightExpression() throws Exception {
    // $NON-NLS-1$
    Like like = example("abc", '.', false);
    assertNotNull(like.getRightExpression());
    assertTrue(like.getRightExpression() instanceof Literal);
    // $NON-NLS-1$
    assertEquals("abc", ((Literal) like.getRightExpression()).getValue());
}
Also used : Like(org.teiid.language.Like) Literal(org.teiid.language.Literal)

Example 2 with Like

use of org.teiid.language.Like in project teiid by teiid.

the class CoherenceVisitor method visit.

public void visit(Like obj) {
    // $NON-NLS-1$
    LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing LIKE criteria.");
    // Convert LIKE to Equals, where any "%" symbol is replaced with "*".
    try {
        Comparison.Operator op = Operator.EQ;
        Expression lhs = ((Like) obj).getLeftExpression();
        Expression rhs = ((Like) obj).getRightExpression();
        String lhsString = getExpressionString(lhs);
        String rhsString = getExpressionString(rhs);
        // rhsString = rhsString.replace("%", "*"); //$NON-NLS-1$ //$NON-NLS-2$
        filter = CoherenceFilterUtil.createFilter(lhsString + " LIKE \'" + rhsString + "\'");
    } catch (TranslatorException t) {
        exception = t;
    }
}
Also used : Like(org.teiid.language.Like) Comparison(org.teiid.language.Comparison) Expression(org.teiid.language.Expression) TranslatorException(org.teiid.translator.TranslatorException) Operator(org.teiid.language.Comparison.Operator)

Aggregations

Like (org.teiid.language.Like)2 Comparison (org.teiid.language.Comparison)1 Operator (org.teiid.language.Comparison.Operator)1 Expression (org.teiid.language.Expression)1 Literal (org.teiid.language.Literal)1 TranslatorException (org.teiid.translator.TranslatorException)1