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

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


    public void testDelete_5() throws Exception {
        String sql = "deLetE id.* from t1,t2 where col1='adf'            and col2=1";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(stmt);
        Assert.assertEquals("DELETE id.*\n" + //
                            "FROM t1, t2\n" + //
                            "WHERE col1 = 'adf'\n" + //
                            "\tAND col2 = 1", output);
View Full Code Here


    public void testDelete_6() throws Exception {
        String sql = "deLetE id,id.t from t1";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(stmt);
        Assert.assertEquals("DELETE id, id.t\n" + //
                            "FROM t1", output);
    }
View Full Code Here

    public void testDelete_7() throws Exception {
        String sql = "deLetE from t1 where t1.id1='abc' order by a limit 5";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(stmt);
        Assert.assertEquals("DELETE FROM t1\n" + //
                            "WHERE t1.id1 = 'abc'\n" + //
                            "ORDER BY a\n" + //
                            "LIMIT 5", output);
View Full Code Here

   
    public void test_show_masterLogs() throws Exception {
        String sql = "SHOW MASTER LOGS ";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowMasterLogsStatement show = (MySqlShowMasterLogsStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW MASTER LOGS", output);
    }
   
    public void test_show_collation() throws Exception {
View Full Code Here

   
    public void test_show_collation() throws Exception {
        String sql = "SHOW collation";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowCollationStatement show = (MySqlShowCollationStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW COLLATION", output);
    }
   
    public void test_show_collation_1() throws Exception {
View Full Code Here

   
    public void test_show_collation_1() throws Exception {
        String sql = "SHOW Collation like 'var1'";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowCollationStatement show = (MySqlShowCollationStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW COLLATION LIKE 'var1'", output);
    }
   
    public void test_show_collation_2() throws Exception {
View Full Code Here

   
    public void test_show_collation_2() throws Exception {
        String sql = "SHOW COLLATION WHERE `Default` = 'Yes'";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowCollationStatement show = (MySqlShowCollationStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW COLLATION WHERE `Default` = 'Yes'", output);
    }
   
    public void test_show_collation_3() throws Exception {
View Full Code Here

   
    public void test_show_collation_3() throws Exception {
        String sql = "SHOW collation where Collation like 'big5%'";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowCollationStatement show = (MySqlShowCollationStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW COLLATION WHERE Collation LIKE 'big5%'", output);
    }
   
    public void test_binaryLog() throws Exception {
View Full Code Here

    public void test_alter_constraint() throws Exception {
        String sql = "alter table TUSER drop constraint UK_084c17821a8f47e8b31fbb126b6";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);
        parser.match(Token.EOF);

        MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
        stmt.accept(visitor);

        System.out.println("Tables : " + visitor.getTables());
View Full Code Here

   
    public void test_binaryLog() throws Exception {
        String sql = "SHOW binlog events in 'a' from 1 limit 1,2  ";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowBinLogEventsStatement show = (MySqlShowBinLogEventsStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW BINLOG EVENTS IN 'a' FROM 1 LIMIT 1, 2", output);
    }
   
    public void test_binaryLog_1() throws Exception {
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.