use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser in project druid by alibaba.
the class EqualTest_unary_mysql method test_exits.
public void test_exits() throws Exception {
String sql = "-a";
String sql_c = "-(a+1 + +(b+1))";
SQLUnaryExpr exprA, exprB, exprC;
{
MySqlExprParser parser = new MySqlExprParser(sql);
exprA = (SQLUnaryExpr) parser.expr();
}
{
MySqlExprParser parser = new MySqlExprParser(sql);
exprB = (SQLUnaryExpr) parser.expr();
}
{
MySqlExprParser parser = new MySqlExprParser(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());
}
use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser 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.dialect.mysql.parser.MySqlExprParser in project druid by alibaba.
the class EqualTest_mysqlMatch method test_exits.
public void test_exits() throws Exception {
String sql = "MATCH (f1, f2) AGAINST (f3 IN BOOLEAN MODE)";
String sql_c = "MATCH (f1, f2) AGAINST (f4 IN BOOLEAN MODE)";
MySqlMatchAgainstExpr exprA, exprB, exprC;
{
MySqlExprParser parser = new MySqlExprParser(sql);
exprA = (MySqlMatchAgainstExpr) parser.expr();
}
{
MySqlExprParser parser = new MySqlExprParser(sql);
exprB = (MySqlMatchAgainstExpr) parser.expr();
}
{
MySqlExprParser parser = new MySqlExprParser(sql_c);
exprC = (MySqlMatchAgainstExpr) 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 MySqlMatchAgainstExpr(), new MySqlMatchAgainstExpr());
Assert.assertEquals(new MySqlMatchAgainstExpr().hashCode(), new MySqlMatchAgainstExpr().hashCode());
exprA.setColumns(null);
exprB.setColumns(null);
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());
}
Aggregations