use of com.alibaba.druid.sql.parser.SQLExprParser in project druid by alibaba.
the class SQLExprParserTest method test_binary.
public void test_binary() throws Exception {
SQLExprParser exprParser = new SQLExprParser("AGE > 5");
SQLBinaryOpExpr binaryOpExpr = (SQLBinaryOpExpr) exprParser.expr();
Assert.assertEquals(SQLBinaryOperator.GreaterThan, binaryOpExpr.getOperator());
SQLIdentifierExpr left = (SQLIdentifierExpr) binaryOpExpr.getLeft();
SQLIntegerExpr right = (SQLIntegerExpr) binaryOpExpr.getRight();
Assert.assertEquals("AGE", left.getName());
Assert.assertEquals(5, right.getNumber().intValue());
}
use of com.alibaba.druid.sql.parser.SQLExprParser in project druid by alibaba.
the class EqualTest_interval_mysql method test_exits.
public void test_exits() throws Exception {
String sql = "INTERVAL 3 YEAR";
String sql_c = "INTERVAL 3 MONTH";
MySqlIntervalExpr exprA, exprB, exprC;
{
SQLExprParser parser = new MySqlExprParser(sql);
exprA = (MySqlIntervalExpr) parser.expr();
}
{
SQLExprParser parser = new MySqlExprParser(sql);
exprB = (MySqlIntervalExpr) parser.expr();
}
{
SQLExprParser parser = new MySqlExprParser(sql_c);
exprC = (MySqlIntervalExpr) 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 MySqlIntervalExpr(), new MySqlIntervalExpr());
Assert.assertEquals(new MySqlIntervalExpr().hashCode(), new MySqlIntervalExpr().hashCode());
}
use of com.alibaba.druid.sql.parser.SQLExprParser in project druid by alibaba.
the class EqualTest_aggreate_over method test_exits.
public void test_exits() throws Exception {
String sql = "count(*) OVER (ORDER BY f1)";
String sql_c = "count(id) OVER (ORDER BY f2)";
SQLAggregateExpr exprA, exprB, exprC;
{
SQLExprParser parser = new SQLExprParser(sql);
exprA = (SQLAggregateExpr) parser.expr();
}
{
SQLExprParser parser = new SQLExprParser(sql);
exprB = (SQLAggregateExpr) parser.expr();
}
{
SQLExprParser parser = new SQLExprParser(sql_c);
exprC = (SQLAggregateExpr) 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 SQLAggregateExpr(null), new SQLAggregateExpr(null));
Assert.assertEquals(new SQLAggregateExpr(null).hashCode(), new SQLAggregateExpr(null).hashCode());
}
Aggregations