use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class AssignmentOperatorsTest method test_1.
public void test_1() throws Exception {
String sql = "SELECT @var1 := 1, @var2;";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT @var1 := 1, @var2;", text);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class AssignmentOperatorsTest method test_2.
public void test_2() throws Exception {
String sql = "SELECT @var1, @var2 := @var1;";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT @var1, @var2 := @var1;", text);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class AssignmentOperatorsTest method output.
private String output(List<SQLStatement> stmtList) {
StringBuilder out = new StringBuilder();
for (SQLStatement stmt : stmtList) {
stmt.accept(new MySqlOutputVisitor(out));
out.append(";");
}
return out.toString();
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class AssignmentOperatorsTest method test_4.
public void test_4() throws Exception {
String sql = "UPDATE t1 SET c1 = 2 WHERE c1 = @var1:= 1;";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("UPDATE t1\nSET c1 = 2\nWHERE c1 = (@var1 := 1);", text);
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class AssignmentOperatorsTest method test_0.
public void test_0() throws Exception {
String sql = "SELECT @var1, @var2;";
SQLStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> stmtList = parser.parseStatementList();
String text = output(stmtList);
Assert.assertEquals("SELECT @var1, @var2;", text);
}
Aggregations