Search in sources :

Example 16 with OracleExprParser

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

the class EqualTest_not_2 method test_exits.

public void test_exits() throws Exception {
    String sql = "NOT A=1 AND NOT B=1";
    SQLNotExpr exprA, exprB;
    {
        OracleExprParser parser = new OracleExprParser(sql);
        SQLBinaryOpExpr binaryEpr = (SQLBinaryOpExpr) parser.expr();
        exprA = (SQLNotExpr) binaryEpr.getLeft();
        exprB = (SQLNotExpr) binaryEpr.getRight();
    }
    Assert.assertNotNull(exprA);
    Assert.assertNotNull(exprB);
}
Also used : OracleExprParser(com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser) SQLNotExpr(com.alibaba.druid.sql.ast.expr.SQLNotExpr) SQLBinaryOpExpr(com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)

Example 17 with OracleExprParser

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

the class EqualTest_any method test_exits.

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

Example 18 with OracleExprParser

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

the class EqualTest_cast method test_exits.

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

Example 19 with OracleExprParser

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

the class EqualTest_cursor method test_exits.

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

Example 20 with OracleExprParser

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

the class EqualTest_dbLink method test_eq.

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

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