Search in sources :

Example 21 with SQLStatementParser

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

the class DateAndTimeFunctionsTest method test_36.

public void test_36() throws Exception {
    String sql = "SELECT FROM_UNIXTIME(1196440219) + 0;";
    SQLStatementParser parser = new MySqlStatementParser(sql);
    List<SQLStatement> stmtList = parser.parseStatementList();
    String text = output(stmtList);
    Assert.assertEquals("SELECT FROM_UNIXTIME(1196440219) + 0;", text);
}
Also used : SQLStatementParser(com.alibaba.druid.sql.parser.SQLStatementParser) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Example 22 with SQLStatementParser

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

the class DateAndTimeFunctionsTest method test_28.

public void test_28() throws Exception {
    String sql = "SELECT INTERVAL '1.999999' SECOND_MICROSECOND;";
    SQLStatementParser parser = new MySqlStatementParser(sql);
    List<SQLStatement> stmtList = parser.parseStatementList();
    String text = output(stmtList);
    Assert.assertEquals("SELECT INTERVAL '1.999999' SECOND_MICROSECOND;", text);
}
Also used : SQLStatementParser(com.alibaba.druid.sql.parser.SQLStatementParser) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Example 23 with SQLStatementParser

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

the class DateAndTimeFunctionsTest method test_5.

public void test_5() throws Exception {
    String sql = "SELECT ADDDATE('2008-01-02', INTERVAL 31 DAY)";
    SQLStatementParser parser = new MySqlStatementParser(sql);
    List<SQLStatement> stmtList = parser.parseStatementList();
    String text = output(stmtList);
    Assert.assertEquals("SELECT ADDDATE('2008-01-02', INTERVAL 31 DAY);", text);
}
Also used : SQLStatementParser(com.alibaba.druid.sql.parser.SQLStatementParser) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Example 24 with SQLStatementParser

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

the class DateAndTimeFunctionsTest method test_3.

public void test_3() throws Exception {
    String sql = "SELECT DAYNAME('2006-05-00')";
    SQLStatementParser parser = new MySqlStatementParser(sql);
    List<SQLStatement> stmtList = parser.parseStatementList();
    String text = output(stmtList);
    Assert.assertEquals("SELECT DAYNAME('2006-05-00');", text);
}
Also used : SQLStatementParser(com.alibaba.druid.sql.parser.SQLStatementParser) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Example 25 with SQLStatementParser

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

the class DateAndTimeFunctionsTest method test_40.

public void test_40() throws Exception {
    String sql = "SELECT SUBDATE('2008-01-02', INTERVAL 31 DAY);";
    SQLStatementParser parser = new MySqlStatementParser(sql);
    List<SQLStatement> stmtList = parser.parseStatementList();
    String text = output(stmtList);
    Assert.assertEquals("SELECT SUBDATE('2008-01-02', INTERVAL 31 DAY);", text);
}
Also used : SQLStatementParser(com.alibaba.druid.sql.parser.SQLStatementParser) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Aggregations

SQLStatementParser (com.alibaba.druid.sql.parser.SQLStatementParser)436 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)431 MySqlStatementParser (com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)382 ArrayList (java.util.ArrayList)21 SQLASTOutputVisitor (com.alibaba.druid.sql.visitor.SQLASTOutputVisitor)19 SchemaStatVisitor (com.alibaba.druid.sql.visitor.SchemaStatVisitor)14 MycatSchemaStatVisitor (io.mycat.route.parser.druid.MycatSchemaStatVisitor)6 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)5 MySqlExportParameterVisitor (com.alibaba.druid.sql.dialect.mysql.visitor.MySqlExportParameterVisitor)5 ExportParameterVisitor (com.alibaba.druid.sql.visitor.ExportParameterVisitor)5 TableStat (com.alibaba.druid.stat.TableStat)5 MycatStatementParser (io.mycat.route.parser.druid.MycatStatementParser)5 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)4 SQLSelectStatement (com.alibaba.druid.sql.ast.statement.SQLSelectStatement)4 OracleStatementParser (com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser)4 SQLVariantRefExpr (com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr)3 SQLSelectQuery (com.alibaba.druid.sql.ast.statement.SQLSelectQuery)3 SQLSelectQueryBlock (com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock)3 MySqlInsertStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement)3 RouteResultset (io.mycat.route.RouteResultset)3