use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser in project druid by alibaba.
the class EqualTest_extract_mysql method test_exits.
public void test_exits() throws Exception {
String sql = "EXTRACT (YEAR FROM x)";
String sql_c = "EXTRACT (MONTH FROM y)";
MySqlExtractExpr exprA, exprB, exprC;
{
MySqlExprParser parser = new MySqlExprParser(sql);
exprA = (MySqlExtractExpr) parser.expr();
}
{
MySqlExprParser parser = new MySqlExprParser(sql);
exprB = (MySqlExtractExpr) parser.expr();
}
{
MySqlExprParser parser = new MySqlExprParser(sql_c);
exprC = (MySqlExtractExpr) 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 MySqlExtractExpr(), new MySqlExtractExpr());
Assert.assertEquals(new MySqlExtractExpr().hashCode(), new MySqlExtractExpr().hashCode());
}
use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser in project druid by alibaba.
the class EqualTest_inquery 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;
{
MySqlExprParser parser = new MySqlExprParser(sql);
exprA = (SQLInSubQueryExpr) parser.expr();
}
{
MySqlExprParser parser = new MySqlExprParser(sql);
exprB = (SQLInSubQueryExpr) parser.expr();
}
{
MySqlExprParser parser = new MySqlExprParser(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());
}
use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser 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());
}
use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser 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());
}
use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser in project druid by alibaba.
the class LiteralHexadecimalTest method test_1.
public void test_1() throws Exception {
String sql = "x'0D0A'";
SQLHexExpr hex = (SQLHexExpr) new MySqlExprParser(sql).expr();
Assert.assertEquals("\r\n", new String(hex.toBytes(), "utf-8"));
}
Aggregations