Search in sources :

Example 1 with SQLExprParser

use of com.alibaba.druid.sql.parser.SQLExprParser in project druid by alibaba.

the class EqualTest_inquery_mysql 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 SQLExprParser(sql);
        exprA = (SQLInSubQueryExpr) parser.expr();
    }
    {
        SQLExprParser parser = new SQLExprParser(sql);
        exprB = (SQLInSubQueryExpr) parser.expr();
    }
    {
        SQLExprParser parser = new SQLExprParser(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 : SQLInSubQueryExpr(com.alibaba.druid.sql.ast.expr.SQLInSubQueryExpr) SQLExprParser(com.alibaba.druid.sql.parser.SQLExprParser)

Example 2 with SQLExprParser

use of com.alibaba.druid.sql.parser.SQLExprParser 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 3 with SQLExprParser

use of com.alibaba.druid.sql.parser.SQLExprParser in project druid by alibaba.

the class EqualTest_orderBy method test_exits.

public void test_exits() throws Exception {
    String sql = "ORDER BY f1";
    String sql_c = "ORDER BY f2";
    SQLOrderBy exprA, exprB, exprC;
    {
        SQLExprParser parser = new SQLExprParser(sql);
        exprA = (SQLOrderBy) parser.parseOrderBy();
    }
    {
        SQLExprParser parser = new SQLExprParser(sql);
        exprB = (SQLOrderBy) parser.parseOrderBy();
    }
    {
        SQLExprParser parser = new SQLExprParser(sql_c);
        exprC = (SQLOrderBy) parser.parseOrderBy();
    }
    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 SQLOrderBy(), new SQLOrderBy());
    Assert.assertEquals(new SQLOrderBy().hashCode(), new SQLOrderBy().hashCode());
    Assert.assertEquals(new SQLSelectOrderByItem(), new SQLSelectOrderByItem());
    Assert.assertEquals(new SQLSelectOrderByItem().hashCode(), new SQLSelectOrderByItem().hashCode());
}
Also used : SQLOrderBy(com.alibaba.druid.sql.ast.SQLOrderBy) SQLSelectOrderByItem(com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem) SQLExprParser(com.alibaba.druid.sql.parser.SQLExprParser)

Example 4 with SQLExprParser

use of com.alibaba.druid.sql.parser.SQLExprParser in project druid by alibaba.

the class EqualTest_binary method test_exits.

public void test_exits() throws Exception {
    String sql = "b'01010'";
    String sql_c = "b'010101'";
    SQLBinaryExpr exprA, exprB, exprC;
    {
        SQLExprParser parser = new MySqlExprParser(sql);
        exprA = (SQLBinaryExpr) parser.expr();
    }
    {
        SQLExprParser parser = new MySqlExprParser(sql);
        exprB = (SQLBinaryExpr) parser.expr();
    }
    {
        SQLExprParser parser = new MySqlExprParser(sql_c);
        exprC = (SQLBinaryExpr) 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 SQLBinaryExpr(), new SQLBinaryExpr());
    Assert.assertEquals(new SQLBinaryExpr().hashCode(), new SQLBinaryExpr().hashCode());
}
Also used : SQLBinaryExpr(com.alibaba.druid.sql.ast.expr.SQLBinaryExpr) MySqlExprParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser) SQLExprParser(com.alibaba.druid.sql.parser.SQLExprParser)

Example 5 with SQLExprParser

use of com.alibaba.druid.sql.parser.SQLExprParser in project druid by alibaba.

the class EqualTest_boolean method test_exits.

public void test_exits() throws Exception {
    String sql = "true";
    String sql_c = "false";
    SQLBooleanExpr exprA, exprB, exprC;
    {
        SQLExprParser parser = new MySqlExprParser(sql);
        exprA = (SQLBooleanExpr) parser.expr();
    }
    {
        SQLExprParser parser = new MySqlExprParser(sql);
        exprB = (SQLBooleanExpr) parser.expr();
    }
    {
        SQLExprParser parser = new MySqlExprParser(sql_c);
        exprC = (SQLBooleanExpr) 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 SQLBooleanExpr(), new SQLBooleanExpr());
    Assert.assertEquals(new SQLBooleanExpr().hashCode(), new SQLBooleanExpr().hashCode());
}
Also used : SQLBooleanExpr(com.alibaba.druid.sql.ast.expr.SQLBooleanExpr) MySqlExprParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser) SQLExprParser(com.alibaba.druid.sql.parser.SQLExprParser)

Aggregations

SQLExprParser (com.alibaba.druid.sql.parser.SQLExprParser)8 MySqlExprParser (com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser)3 SQLInSubQueryExpr (com.alibaba.druid.sql.ast.expr.SQLInSubQueryExpr)2 SQLOrderBy (com.alibaba.druid.sql.ast.SQLOrderBy)1 SQLAggregateExpr (com.alibaba.druid.sql.ast.expr.SQLAggregateExpr)1 SQLBinaryExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryExpr)1 SQLBinaryOpExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)1 SQLBooleanExpr (com.alibaba.druid.sql.ast.expr.SQLBooleanExpr)1 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)1 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)1 SQLSelectOrderByItem (com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem)1 MySqlIntervalExpr (com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr)1 OracleExprParser (com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser)1