Package com.alibaba.druid.sql.dialect.mysql.parser

Examples of com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseStatementList()


    public void test_0() throws Exception {
        String sql = "SHOW FULL COLUMNS FROM `sonar`.`action_plans`";

        MySqlStatementParser parser = new MySqlStatementParser(sql);
        List<SQLStatement> statementList = parser.parseStatementList();
        SQLStatement statemen = statementList.get(0);
        print(statementList);

        Assert.assertEquals(1, statementList.size());
View Full Code Here


public class MySqlAlterTableAddPrimaryKey extends TestCase {

    public void test_alter_first() throws Exception {
        String sql = "ALTER TABLE `test`.`tb1` CHANGE COLUMN `fid` `fid` INT(11) NOT NULL DEFAULT NULL, ADD PRIMARY KEY (`fid`) ;";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(stmt);
        Assert.assertEquals("ALTER TABLE `test`.`tb1`" + //
                            "\n\tCHANGE COLUMN `fid` `fid` INT(11) NULL NOT NULL,\n\t" + //
                            "ADD PRIMARY KEY (`fid`)", output);
View Full Code Here

public class MySql57Test extends TestCase {
    public void test_0() throws Exception {
        String sql = "ALTER TABLE t1 ALGORITHM=INPLACE, CHANGE COLUMN c1 c1 VARCHAR(255);";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(stmt);
        Assert.assertEquals("ALTER TABLE t1" //
                + "\n\tALGORITHM = INPLACE," //
                + "\n\tCHANGE COLUMN c1 c1 VARCHAR(255)", output);
View Full Code Here

    public void test_0() throws Exception {
        String sql = "SELECT 0x5061756c;";

        SQLStatementParser parser = new MySqlStatementParser(sql);
        List<SQLStatement> stmtList = parser.parseStatementList();

        String text = output(stmtList);

        Assert.assertEquals("SELECT 0x5061756c;", text);
    }
View Full Code Here

    public void test_1() throws Exception {
        String sql = "SELECT X'4D7953514C';";

        SQLStatementParser parser = new MySqlStatementParser(sql);
        List<SQLStatement> stmtList = parser.parseStatementList();

        String text = output(stmtList);

        Assert.assertEquals("SELECT 0x4D7953514C;", text);
    }
View Full Code Here

    public void test_2() throws Exception {
        String sql = "SELECT x'4D7953514C';";

        SQLStatementParser parser = new MySqlStatementParser(sql);
        List<SQLStatement> stmtList = parser.parseStatementList();

        String text = output(stmtList);

        Assert.assertEquals("SELECT 0x4D7953514C;", text);
    }
View Full Code Here

    public void test_3() throws Exception {
        String sql = "SELECT 0x65 USING utf8;";

        SQLStatementParser parser = new MySqlStatementParser(sql);
        List<SQLStatement> stmtList = parser.parseStatementList();

        String text = output(stmtList);

        Assert.assertEquals("SELECT 0x65 USING utf8;", text);
    }
View Full Code Here

    public void test_4() throws Exception {
        String sql = "SELECT 0x41, CAST(0x41 AS UNSIGNED)";

        SQLStatementParser parser = new MySqlStatementParser(sql);
        List<SQLStatement> stmtList = parser.parseStatementList();

        String text = output(stmtList);

        Assert.assertEquals("SELECT 0x41, CAST(0x41 AS UNSIGNED);", text);
    }
View Full Code Here

    public void test_5() throws Exception {
        String sql = "SELECT HEX('cat')";

        SQLStatementParser parser = new MySqlStatementParser(sql);
        List<SQLStatement> stmtList = parser.parseStatementList();

        String text = output(stmtList);

        Assert.assertEquals("SELECT HEX('cat');", text);
    }
View Full Code Here

    public void test_0() throws Exception {
        String sql = "select * from tb order by id asc,name desc";

        MySqlStatementParser parser = new MySqlStatementParser(sql);
        List<SQLStatement> statementList = parser.parseStatementList();
        SQLStatement stmt = statementList.get(0);
       
        SQLSelectStatement selectStmt = (SQLSelectStatement) stmt;
       
        SQLSelect select = selectStmt.getSelect();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.