Search in sources :

Example 1 with OracleExprParser

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

the class EqualTest_inquery_oracle method test_exits.

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

Example 2 with OracleExprParser

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

the class EqualTest_extract_oracle method test_exits.

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

Example 3 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 4 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 5 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)

Aggregations

OracleExprParser (com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser)21 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 SQLDbLinkExpr (com.alibaba.druid.sql.ast.expr.SQLDbLinkExpr)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 MySqlKey (com.alibaba.druid.sql.dialect.mysql.ast.MySqlKey)1