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

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


   
    public void test_show_events_1() throws Exception {
        String sql = "SHOW EVENTS from x";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowEventsStatement show = (MySqlShowEventsStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW EVENTS FROM x", output);
    }
   
    public void test_show_events_2() throws Exception {
View Full Code Here


   
    public void test_show_events_2() throws Exception {
        String sql = "SHOW EVENTS in x";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowEventsStatement show = (MySqlShowEventsStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW EVENTS FROM x", output);
    }
   
    public void test_show_events_3() throws Exception {
View Full Code Here

   
    public void test_show_status() throws Exception {
        String sql = "SHOW STATUS LIKE 'Key%'";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowStatusStatement show = (MySqlShowStatusStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW STATUS LIKE 'Key%'", output);
    }
   
    public void test_show_table_status() throws Exception {
View Full Code Here

   
    public void test_show_table_status() throws Exception {
        String sql = "SHOW TABLE STATUS FROM mysql";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowTableStatusStatement show = (MySqlShowTableStatusStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW TABLE STATUS FROM mysql", output);
    }
   
    public void test_show_triggers() throws Exception {
View Full Code Here

   
    public void test_show_triggers() throws Exception {
        String sql = "SHOW TRIGGERS LIKE 'acc%'";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowTriggersStatement show = (MySqlShowTriggersStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW TRIGGERS LIKE 'acc%'", output);
    }
   
    public void test_show_variants() throws Exception {
View Full Code Here

   
    public void test_show_variants() throws Exception {
        String sql = "SHOW VARIABLES LIKE '%size%';";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowVariantsStatement show = (MySqlShowVariantsStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW VARIABLES LIKE '%size%'", output);
    }
   
    public void test_show_variants_1() throws Exception {
View Full Code Here

   
    public void test_show_variants_1() throws Exception {
        String sql = "SHOW GLOBAL VARIABLES LIKE '%size%';";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowVariantsStatement show = (MySqlShowVariantsStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW GLOBAL VARIABLES LIKE '%size%'", output);
    }
   
    public void test_show_variants_2() throws Exception {
View Full Code Here

   
    public void test_show_variants_2() throws Exception {
        String sql = "SHOW SESSION VARIABLES LIKE '%size%';";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        MySqlShowVariantsStatement show = (MySqlShowVariantsStatement) parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(show);
        Assert.assertEquals("SHOW SESSION VARIABLES LIKE '%size%'", output);
    }
   
//
View Full Code Here

    public void testInsert_0() throws Exception {
        String sql = "insErt HIGH_PRIORITY intO test.t1 seT t1.id1=?, id2 := '123'";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(stmt);
        Assert.assertEquals("INSERT HIGH_PRIORITY INTO test.t1 (t1.id1, id2)\n" + //
                            "VALUES (?, '123')", output);
    }
View Full Code Here

    public void testInsert_1() throws Exception {
        String sql = "insErt  IGNORE test.t1 seT t1.id1:=? oN dupLicatE key UPDATE ex.col1=?, col2=12";
        MySqlStatementParser parser = new MySqlStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);
        parser.match(Token.EOF);
        String output = SQLUtils.toMySqlString(stmt);
        Assert.assertEquals("INSERT IGNORE INTO test.t1 (t1.id1)\nVALUES (?)" + //
                            "\nON DUPLICATE KEY UPDATE ex.col1 = ?, col2 = 12", output);
    }
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.