Search in sources :

Example 6 with OracleExprParser

use of com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser in project druid by alibaba.

the class EqualTest_number method test_exits.

public void test_exits() throws Exception {
    String sql = "3.5";
    String sql_c = "3.51";
    SQLNumberExpr exprA, exprB, exprC;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprA = (SQLNumberExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprB = (SQLNumberExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql_c);
        exprC = (SQLNumberExpr) parser.expr();
    }
    Assert.assertEquals(exprA, exprB);
    Assert.assertNotEquals(exprA, exprC);
    Assert.assertTrue(exprA.equals(exprA));
    Assert.assertFalse(exprA.equals(new Object()));
    Assert.assertEquals(exprA.hashCode(), exprB.hashCode());
    Assert.assertEquals(new SQLNumberExpr(), new SQLNumberExpr());
    Assert.assertEquals(new SQLNumberExpr().hashCode(), new SQLNumberExpr().hashCode());
}
Also used : OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser) SQLNumberExpr(com.alibaba.druid.sql.ast.expr.SQLNumberExpr)

Example 7 with OracleExprParser

use of com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser in project druid by alibaba.

the class EqualTest_some method test_exits.

public void test_exits() throws Exception {
    String sql = "some(select id from t)";
    String sql_c = "some(select id from t1)";
    SQLSomeExpr exprA, exprB, exprC;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprA = (SQLSomeExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprB = (SQLSomeExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql_c);
        exprC = (SQLSomeExpr) parser.expr();
    }
    Assert.assertEquals(exprA, exprB);
    Assert.assertNotEquals(exprA, exprC);
    Assert.assertTrue(exprA.equals(exprA));
    Assert.assertFalse(exprA.equals(new Object()));
    Assert.assertEquals(exprA.hashCode(), exprB.hashCode());
    Assert.assertEquals(new SQLSomeExpr(), new SQLSomeExpr());
    Assert.assertEquals(new SQLSomeExpr().hashCode(), new SQLSomeExpr().hashCode());
}
Also used : OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser) SQLSomeExpr(com.alibaba.druid.sql.ast.expr.SQLSomeExpr)

Example 8 with OracleExprParser

use of com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser in project druid by alibaba.

the class EqualTest_between method test_exits.

public void test_exits() throws Exception {
    String sql = "x between 1 AND 2";
    String sql_c = "x between 1 AND 3";
    SQLBetweenExpr exprA, exprB, exprC;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprA = (SQLBetweenExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprB = (SQLBetweenExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql_c);
        exprC = (SQLBetweenExpr) parser.expr();
    }
    Assert.assertEquals(exprA, exprB);
    Assert.assertNotEquals(exprA, exprC);
    Assert.assertTrue(exprA.equals(exprA));
    Assert.assertFalse(exprA.equals(new Object()));
    Assert.assertEquals(exprA.hashCode(), exprB.hashCode());
    Assert.assertEquals(new SQLBetweenExpr(), new SQLBetweenExpr());
    Assert.assertEquals(new SQLBetweenExpr().hashCode(), new SQLBetweenExpr().hashCode());
}
Also used : OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser) SQLBetweenExpr(com.alibaba.druid.sql.ast.expr.SQLBetweenExpr)

Example 9 with OracleExprParser

use of com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser in project druid by alibaba.

the class EqualTest_binaryOp method test_exits.

public void test_exits() throws Exception {
    String sql = "a > b";
    String sql_c = "a > 2";
    SQLBinaryOpExpr exprA, exprB, exprC;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprA = (SQLBinaryOpExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprB = (SQLBinaryOpExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql_c);
        exprC = (SQLBinaryOpExpr) parser.expr();
    }
    Assert.assertEquals(exprA, exprB);
    Assert.assertNotEquals(exprA, exprC);
    Assert.assertTrue(exprA.equals(exprA));
    Assert.assertFalse(exprA.equals(new Object()));
    Assert.assertEquals(exprA.hashCode(), exprB.hashCode());
    Assert.assertEquals(new SQLBinaryOpExpr(), new SQLBinaryOpExpr());
    Assert.assertEquals(new SQLBinaryOpExpr().hashCode(), new SQLBinaryOpExpr().hashCode());
}
Also used : OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser) SQLBinaryOpExpr(com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)

Example 10 with OracleExprParser

use of com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser in project druid by alibaba.

the class EqualTest_case method test_exits.

public void test_exits() throws Exception {
    String sql = "case x when 1 then 0 else 2 end";
    String sql_c = "case x when 2 then 0 else 2 end";
    SQLCaseExpr exprA, exprB, exprC;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprA = (SQLCaseExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprB = (SQLCaseExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql_c);
        exprC = (SQLCaseExpr) parser.expr();
    }
    Assert.assertEquals(exprA, exprB);
    Assert.assertNotEquals(exprA, exprC);
    Assert.assertTrue(exprA.equals(exprA));
    Assert.assertFalse(exprA.equals(new Object()));
    Assert.assertEquals(exprA.hashCode(), exprB.hashCode());
    Assert.assertEquals(new SQLCaseExpr(), new SQLCaseExpr());
    Assert.assertEquals(new SQLCaseExpr().hashCode(), new SQLCaseExpr().hashCode());
}
Also used : OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser) SQLCaseExpr(com.alibaba.druid.sql.ast.expr.SQLCaseExpr)

Aggregations

OracleExprParser (com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser)20 SQLBinaryOpExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)2 SQLNotExpr (com.alibaba.druid.sql.ast.expr.SQLNotExpr)2 SQLDataTypeImpl (com.alibaba.druid.sql.ast.SQLDataTypeImpl)1 SQLAggregateExpr (com.alibaba.druid.sql.ast.expr.SQLAggregateExpr)1 SQLAnyExpr (com.alibaba.druid.sql.ast.expr.SQLAnyExpr)1 SQLBetweenExpr (com.alibaba.druid.sql.ast.expr.SQLBetweenExpr)1 SQLCaseExpr (com.alibaba.druid.sql.ast.expr.SQLCaseExpr)1 SQLCastExpr (com.alibaba.druid.sql.ast.expr.SQLCastExpr)1 SQLExistsExpr (com.alibaba.druid.sql.ast.expr.SQLExistsExpr)1 SQLInListExpr (com.alibaba.druid.sql.ast.expr.SQLInListExpr)1 SQLInSubQueryExpr (com.alibaba.druid.sql.ast.expr.SQLInSubQueryExpr)1 SQLMethodInvokeExpr (com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr)1 SQLNumberExpr (com.alibaba.druid.sql.ast.expr.SQLNumberExpr)1 SQLQueryExpr (com.alibaba.druid.sql.ast.expr.SQLQueryExpr)1 SQLSomeExpr (com.alibaba.druid.sql.ast.expr.SQLSomeExpr)1 SQLTimestampExpr (com.alibaba.druid.sql.ast.expr.SQLTimestampExpr)1 SQLUnaryExpr (com.alibaba.druid.sql.ast.expr.SQLUnaryExpr)1 OracleCursorExpr (com.alibaba.druid.sql.dialect.oracle.ast.expr.OracleCursorExpr)1 OracleDbLinkExpr (com.alibaba.druid.sql.dialect.oracle.ast.expr.OracleDbLinkExpr)1