Search in sources :

Example 11 with OracleExprParser

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

the class EqualTest_exists method test_exits.

public void test_exits() throws Exception {
    String sql = "exists (select 1)";
    String sql_c = "not exists (select 1)";
    SQLExistsExpr exprA, exprB, exprC;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprA = (SQLExistsExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprB = (SQLExistsExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql_c);
        exprC = (SQLExistsExpr) 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 SQLExistsExpr(), new SQLExistsExpr());
    Assert.assertEquals(new SQLExistsExpr().hashCode(), new SQLExistsExpr().hashCode());
}
Also used : OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser) SQLExistsExpr(com.alibaba.druid.sql.ast.expr.SQLExistsExpr)

Example 12 with OracleExprParser

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

the class EqualTest_query method test_exits.

public void test_exits() throws Exception {
    String sql = "(select id from t)";
    String sql_c = "(select id from t1)";
    SQLQueryExpr exprA, exprB, exprC;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprA = (SQLQueryExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprB = (SQLQueryExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql_c);
        exprC = (SQLQueryExpr) 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 SQLQueryExpr(), new SQLQueryExpr());
    Assert.assertEquals(new SQLQueryExpr().hashCode(), new SQLQueryExpr().hashCode());
}
Also used : OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser) SQLQueryExpr(com.alibaba.druid.sql.ast.expr.SQLQueryExpr)

Example 13 with OracleExprParser

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

the class EqualTest_unary method test_exits.

public void test_exits() throws Exception {
    String sql = "-a";
    String sql_c = "-(a+1 + +(b+1))";
    SQLUnaryExpr exprA, exprB, exprC;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprA = (SQLUnaryExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprB = (SQLUnaryExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql_c);
        exprC = (SQLUnaryExpr) 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 SQLUnaryExpr(), new SQLUnaryExpr());
    Assert.assertEquals(new SQLUnaryExpr().hashCode(), new SQLUnaryExpr().hashCode());
}
Also used : OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser) SQLUnaryExpr(com.alibaba.druid.sql.ast.expr.SQLUnaryExpr)

Example 14 with OracleExprParser

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

the class EqualTest_inList method test_exits.

public void test_exits() throws Exception {
    String sql = "x in (1, 2, 3)";
    String sql_c = "x not in (1, 2, 3)";
    SQLInListExpr exprA, exprB, exprC;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprA = (SQLInListExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprB = (SQLInListExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql_c);
        exprC = (SQLInListExpr) 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 SQLInListExpr(), new SQLInListExpr());
    Assert.assertEquals(new SQLInListExpr().hashCode(), new SQLInListExpr().hashCode());
}
Also used : SQLInListExpr(com.alibaba.druid.sql.ast.expr.SQLInListExpr) OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser)

Example 15 with OracleExprParser

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

the class EqualTest_not method test_exits.

public void test_exits() throws Exception {
    String sql = "not f1 = f2";
    String sql_c = "not f1 = f3";
    SQLNotExpr exprA, exprB, exprC;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprA = (SQLNotExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql);
        exprB = (SQLNotExpr) parser.expr();
    }
    {
        OracleExprParser parser = new OracleExprParser(sql_c);
        exprC = (SQLNotExpr) 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 SQLNotExpr(), new SQLNotExpr());
    Assert.assertEquals(new SQLNotExpr().hashCode(), new SQLNotExpr().hashCode());
}
Also used : OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser) SQLNotExpr(com.alibaba.druid.sql.ast.expr.SQLNotExpr)

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