Search in sources :

Example 46 with SQLSyntaxErrorException

use of java.sql.SQLSyntaxErrorException in project cobar by alibaba.

the class MySQLDDLParser method createTable.

/**
 * <code>TABLE</code> has been consumed
 */
private DDLCreateTableStatement createTable(boolean temp) throws SQLSyntaxErrorException {
    boolean ifNotExists = false;
    if (lexer.token() == KW_IF) {
        lexer.nextToken();
        match(KW_NOT);
        match(KW_EXISTS);
        ifNotExists = true;
    }
    Identifier table = identifier();
    DDLCreateTableStatement stmt = new DDLCreateTableStatement(temp, ifNotExists, table);
    createTableDefs(stmt);
    TableOptions options = new TableOptions();
    stmt.setTableOptions(options);
    tableOptions(options);
    DDLCreateTableStatement.SelectOption selectOpt = null;
    switch(lexer.token()) {
        case KW_IGNORE:
            selectOpt = DDLCreateTableStatement.SelectOption.IGNORED;
            if (lexer.nextToken() == KW_AS) {
                lexer.nextToken();
            }
            break;
        case KW_REPLACE:
            selectOpt = DDLCreateTableStatement.SelectOption.REPLACE;
            if (lexer.nextToken() == KW_AS) {
                lexer.nextToken();
            }
            break;
        case KW_AS:
            lexer.nextToken();
        case KW_SELECT:
            break;
        case EOF:
            return stmt;
        default:
            throw new SQLSyntaxErrorException("DDL CREATE TABLE statement not end properly");
    }
    DMLSelectStatement select = new MySQLDMLSelectParser(lexer, exprParser).select();
    stmt.setSelect(selectOpt, select);
    match(EOF);
    return stmt;
}
Also used : Identifier(com.alibaba.cobar.parser.ast.expression.primary.Identifier) TableOptions(com.alibaba.cobar.parser.ast.fragment.ddl.TableOptions) SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) DMLSelectStatement(com.alibaba.cobar.parser.ast.stmt.dml.DMLSelectStatement) DDLCreateTableStatement(com.alibaba.cobar.parser.ast.stmt.ddl.DDLCreateTableStatement)

Example 47 with SQLSyntaxErrorException

use of java.sql.SQLSyntaxErrorException in project cobar by alibaba.

the class MySQLDDLParser method alterTable.

/**
 * token of table name has been consumed
 *
 * @throws SQLSyntaxErrorException
 */
private DDLAlterTableStatement alterTable(DDLAlterTableStatement stmt) throws SQLSyntaxErrorException {
    TableOptions options = new TableOptions();
    stmt.setTableOptions(options);
    Identifier id = null;
    Identifier id2 = null;
    Identifier id3 = null;
    ColumnDefinition colDef = null;
    IndexDefinition indexDef = null;
    Expression expr = null;
    for (int i = 0; lexer.token() != EOF; ++i) {
        if (i > 0) {
            match(PUNC_COMMA);
        }
        if (tableOptions(options)) {
            continue;
        }
        main_switch: switch(lexer.token()) {
            case KW_CONVERT:
                // | CONVERT TO CHARACTER SET charset_name [COLLATE
                // collation_name]
                lexer.nextToken();
                match(KW_TO);
                match(KW_CHARACTER);
                match(KW_SET);
                id = identifier();
                id2 = null;
                if (lexer.token() == KW_COLLATE) {
                    lexer.nextToken();
                    id2 = identifier();
                }
                stmt.setConvertCharset(new Pair<Identifier, Identifier>(id, id2));
                break main_switch;
            case KW_RENAME:
                // | RENAME [TO] new_tbl_name
                if (lexer.nextToken() == KW_TO) {
                    lexer.nextToken();
                }
                id = identifier();
                stmt.setRenameTo(id);
                break main_switch;
            case KW_DROP:
                drop_switch: switch(lexer.nextToken()) {
                    case KW_INDEX:
                    case KW_KEY:
                        // | DROP {INDEX|KEY} index_name
                        lexer.nextToken();
                        id = identifier();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.DropIndex(id));
                        break drop_switch;
                    case KW_PRIMARY:
                        // | DROP PRIMARY KEY
                        lexer.nextToken();
                        match(KW_KEY);
                        stmt.addAlterSpecification(new DDLAlterTableStatement.DropPrimaryKey());
                        break drop_switch;
                    case IDENTIFIER:
                        // | DROP [COLUMN] col_name
                        id = identifier();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.DropColumn(id));
                        break drop_switch;
                    case KW_COLUMN:
                        // | DROP [COLUMN] col_name
                        lexer.nextToken();
                        id = identifier();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.DropColumn(id));
                        break drop_switch;
                    default:
                        throw new SQLSyntaxErrorException("ALTER TABLE error for DROP");
                }
                break main_switch;
            case KW_CHANGE:
                // [FIRST|AFTER col_name]
                if (lexer.nextToken() == KW_COLUMN) {
                    lexer.nextToken();
                }
                id = identifier();
                id2 = identifier();
                colDef = columnDefinition();
                if (lexer.token() == IDENTIFIER) {
                    if ("FIRST".equals(lexer.stringValueUppercase())) {
                        lexer.nextToken();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.ChangeColumn(id, id2, colDef, null));
                    } else if ("AFTER".equals(lexer.stringValueUppercase())) {
                        lexer.nextToken();
                        id3 = identifier();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.ChangeColumn(id, id2, colDef, id3));
                    } else {
                        stmt.addAlterSpecification(new DDLAlterTableStatement.ChangeColumn(id, id2, colDef));
                    }
                } else {
                    stmt.addAlterSpecification(new DDLAlterTableStatement.ChangeColumn(id, id2, colDef));
                }
                break main_switch;
            case KW_ALTER:
                // DEFAULT}
                if (lexer.nextToken() == KW_COLUMN) {
                    lexer.nextToken();
                }
                id = identifier();
                switch(lexer.token()) {
                    case KW_SET:
                        lexer.nextToken();
                        match(KW_DEFAULT);
                        expr = exprParser.expression();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.AlterColumnDefaultVal(id, expr));
                        break;
                    case KW_DROP:
                        lexer.nextToken();
                        match(KW_DEFAULT);
                        stmt.addAlterSpecification(new DDLAlterTableStatement.AlterColumnDefaultVal(id));
                        break;
                    default:
                        throw new SQLSyntaxErrorException("ALTER TABLE error for ALTER");
                }
                break main_switch;
            case KW_ADD:
                add_switch: switch(lexer.nextToken()) {
                    case IDENTIFIER:
                        // | ADD [COLUMN] col_name column_definition [FIRST | AFTER
                        // col_name ]
                        id = identifier();
                        colDef = columnDefinition();
                        if (lexer.token() == IDENTIFIER) {
                            if ("FIRST".equals(lexer.stringValueUppercase())) {
                                lexer.nextToken();
                                stmt.addAlterSpecification(new DDLAlterTableStatement.AddColumn(id, colDef, null));
                            } else if ("AFTER".equals(lexer.stringValueUppercase())) {
                                lexer.nextToken();
                                id2 = identifier();
                                stmt.addAlterSpecification(new DDLAlterTableStatement.AddColumn(id, colDef, id2));
                            } else {
                                stmt.addAlterSpecification(new DDLAlterTableStatement.AddColumn(id, colDef));
                            }
                        } else {
                            stmt.addAlterSpecification(new DDLAlterTableStatement.AddColumn(id, colDef));
                        }
                        break add_switch;
                    case PUNC_LEFT_PAREN:
                        // | ADD [COLUMN] (col_name column_definition,...)
                        lexer.nextToken();
                        for (int j = 0; lexer.token() != PUNC_RIGHT_PAREN; ++j) {
                            DDLAlterTableStatement.AddColumns addColumns = new DDLAlterTableStatement.AddColumns();
                            stmt.addAlterSpecification(addColumns);
                            if (j > 0) {
                                match(PUNC_COMMA);
                            }
                            id = identifier();
                            colDef = columnDefinition();
                            addColumns.addColumn(id, colDef);
                        }
                        match(PUNC_RIGHT_PAREN);
                        break add_switch;
                    case KW_COLUMN:
                        if (lexer.nextToken() == PUNC_LEFT_PAREN) {
                            // | ADD [COLUMN] (col_name column_definition,...)
                            lexer.nextToken();
                            for (int j = 0; lexer.token() != PUNC_RIGHT_PAREN; ++j) {
                                DDLAlterTableStatement.AddColumns addColumns = new DDLAlterTableStatement.AddColumns();
                                stmt.addAlterSpecification(addColumns);
                                if (j > 0) {
                                    match(PUNC_COMMA);
                                }
                                id = identifier();
                                colDef = columnDefinition();
                                addColumns.addColumn(id, colDef);
                            }
                            match(PUNC_RIGHT_PAREN);
                        } else {
                            // | ADD [COLUMN] col_name column_definition [FIRST |
                            // AFTER col_name ]
                            id = identifier();
                            colDef = columnDefinition();
                            if (lexer.token() == IDENTIFIER) {
                                if ("FIRST".equals(lexer.stringValueUppercase())) {
                                    lexer.nextToken();
                                    stmt.addAlterSpecification(new DDLAlterTableStatement.AddColumn(id, colDef, null));
                                } else if ("AFTER".equals(lexer.stringValueUppercase())) {
                                    lexer.nextToken();
                                    id2 = identifier();
                                    stmt.addAlterSpecification(new DDLAlterTableStatement.AddColumn(id, colDef, id2));
                                } else {
                                    stmt.addAlterSpecification(new DDLAlterTableStatement.AddColumn(id, colDef));
                                }
                            } else {
                                stmt.addAlterSpecification(new DDLAlterTableStatement.AddColumn(id, colDef));
                            }
                        }
                        break add_switch;
                    case KW_INDEX:
                    case KW_KEY:
                        // | ADD {INDEX|KEY} [index_name] [index_type]
                        // (index_col_name,...) [index_option] ...
                        id = null;
                        if (lexer.nextToken() == IDENTIFIER) {
                            id = identifier();
                        }
                        indexDef = indexDefinition();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.AddIndex(id, indexDef));
                        break add_switch;
                    case KW_PRIMARY:
                        // | ADD PRIMARY KEY [index_type] (index_col_name,...)
                        // [index_option] ...
                        lexer.nextToken();
                        match(KW_KEY);
                        indexDef = indexDefinition();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.AddPrimaryKey(indexDef));
                        break add_switch;
                    case KW_UNIQUE:
                        // (index_col_name,...) [index_option] ...
                        switch(lexer.nextToken()) {
                            case KW_INDEX:
                            case KW_KEY:
                                lexer.nextToken();
                        }
                        id = null;
                        if (lexer.token() == IDENTIFIER) {
                            id = identifier();
                        }
                        indexDef = indexDefinition();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.AddUniqueKey(id, indexDef));
                        break add_switch;
                    case KW_FULLTEXT:
                        // (index_col_name,...) [index_option] ...
                        switch(lexer.nextToken()) {
                            case KW_INDEX:
                            case KW_KEY:
                                lexer.nextToken();
                        }
                        id = null;
                        if (lexer.token() == IDENTIFIER) {
                            id = identifier();
                        }
                        indexDef = indexDefinition();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.AddFullTextIndex(id, indexDef));
                        break add_switch;
                    case KW_SPATIAL:
                        // (index_col_name,...) [index_option] ...
                        switch(lexer.nextToken()) {
                            case KW_INDEX:
                            case KW_KEY:
                                lexer.nextToken();
                        }
                        id = null;
                        if (lexer.token() == IDENTIFIER) {
                            id = identifier();
                        }
                        indexDef = indexDefinition();
                        stmt.addAlterSpecification(new DDLAlterTableStatement.AddSpatialIndex(id, indexDef));
                        break add_switch;
                    default:
                        throw new SQLSyntaxErrorException("ALTER TABLE error for ADD");
                }
                break main_switch;
            case IDENTIFIER:
                SpecialIdentifier si = specialIdentifiers.get(lexer.stringValueUppercase());
                if (si != null) {
                    switch(si) {
                        case IMPORT:
                            // | IMPORT TABLESPACE
                            lexer.nextToken();
                            matchIdentifier("TABLESPACE");
                            stmt.setImportTableSpace(true);
                            break main_switch;
                        case DISCARD:
                            // | DISCARD TABLESPACE
                            lexer.nextToken();
                            matchIdentifier("TABLESPACE");
                            stmt.setDiscardTableSpace(true);
                            break main_switch;
                        case ENABLE:
                            // | ENABLE KEYS
                            lexer.nextToken();
                            match(KW_KEYS);
                            stmt.setEnableKeys(true);
                            break main_switch;
                        case DISABLE:
                            // | DISABLE KEYS
                            lexer.nextToken();
                            match(KW_KEYS);
                            stmt.setDisableKeys(true);
                            break main_switch;
                        case MODIFY:
                            // AFTER col_name]
                            if (lexer.nextToken() == KW_COLUMN) {
                                lexer.nextToken();
                            }
                            id = identifier();
                            colDef = columnDefinition();
                            if (lexer.token() == IDENTIFIER) {
                                if ("FIRST".equals(lexer.stringValueUppercase())) {
                                    lexer.nextToken();
                                    stmt.addAlterSpecification(new DDLAlterTableStatement.ModifyColumn(id, colDef, null));
                                } else if ("AFTER".equals(lexer.stringValueUppercase())) {
                                    lexer.nextToken();
                                    id2 = identifier();
                                    stmt.addAlterSpecification(new DDLAlterTableStatement.ModifyColumn(id, colDef, id2));
                                } else {
                                    stmt.addAlterSpecification(new DDLAlterTableStatement.ModifyColumn(id, colDef));
                                }
                            } else {
                                stmt.addAlterSpecification(new DDLAlterTableStatement.ModifyColumn(id, colDef));
                            }
                            break main_switch;
                    }
                }
            default:
                throw new SQLSyntaxErrorException("unknown ALTER specification");
        }
    }
    return stmt;
}
Also used : SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) DDLAlterTableStatement(com.alibaba.cobar.parser.ast.stmt.ddl.DDLAlterTableStatement) TableOptions(com.alibaba.cobar.parser.ast.fragment.ddl.TableOptions) Identifier(com.alibaba.cobar.parser.ast.expression.primary.Identifier) IndexDefinition(com.alibaba.cobar.parser.ast.fragment.ddl.index.IndexDefinition) Pair(com.alibaba.cobar.parser.util.Pair) ColumnDefinition(com.alibaba.cobar.parser.ast.fragment.ddl.ColumnDefinition) Expression(com.alibaba.cobar.parser.ast.expression.Expression)

Example 48 with SQLSyntaxErrorException

use of java.sql.SQLSyntaxErrorException in project cobar by alibaba.

the class SQLParserDelegate method parse.

public static SQLStatement parse(String sql, MySQLLexer lexer, String charset) throws SQLSyntaxErrorException {
    try {
        SQLStatement stmt = null;
        boolean isEOF = true;
        MySQLExprParser exprParser = new MySQLExprParser(lexer, charset);
        stmtSwitch: switch(lexer.token()) {
            case KW_DESC:
            case KW_DESCRIBE:
                stmt = new MySQLDALParser(lexer, exprParser).desc();
                break stmtSwitch;
            case KW_SELECT:
            case PUNC_LEFT_PAREN:
                stmt = new MySQLDMLSelectParser(lexer, exprParser).selectUnion();
                break stmtSwitch;
            case KW_DELETE:
                stmt = new MySQLDMLDeleteParser(lexer, exprParser).delete();
                break stmtSwitch;
            case KW_INSERT:
                stmt = new MySQLDMLInsertParser(lexer, exprParser).insert();
                break stmtSwitch;
            case KW_REPLACE:
                stmt = new MySQLDMLReplaceParser(lexer, exprParser).replace();
                break stmtSwitch;
            case KW_UPDATE:
                stmt = new MySQLDMLUpdateParser(lexer, exprParser).update();
                break stmtSwitch;
            case KW_CALL:
                stmt = new MySQLDMLCallParser(lexer, exprParser).call();
                break stmtSwitch;
            case KW_SET:
                stmt = new MySQLDALParser(lexer, exprParser).set();
                break stmtSwitch;
            case KW_SHOW:
                stmt = new MySQLDALParser(lexer, exprParser).show();
                break stmtSwitch;
            case KW_ALTER:
            case KW_CREATE:
            case KW_DROP:
            case KW_RENAME:
                stmt = new MySQLDDLParser(lexer, exprParser).ddlStmt();
                isEOF = isEOFedDDL(stmt);
                break stmtSwitch;
            case KW_RELEASE:
                stmt = new MySQLMTSParser(lexer).release();
                break stmtSwitch;
            case IDENTIFIER:
                SpecialIdentifier si = null;
                if ((si = specialIdentifiers.get(lexer.stringValueUppercase())) != null) {
                    switch(si) {
                        case TRUNCATE:
                            stmt = new MySQLDDLParser(lexer, exprParser).truncate();
                            break stmtSwitch;
                        case SAVEPOINT:
                            stmt = new MySQLMTSParser(lexer).savepoint();
                            break stmtSwitch;
                        case ROLLBACK:
                            stmt = new MySQLMTSParser(lexer).rollback();
                            break stmtSwitch;
                    }
                }
            default:
                throw new SQLSyntaxErrorException("sql is not a supported statement");
        }
        if (isEOF) {
            while (lexer.token() == MySQLToken.PUNC_SEMICOLON) {
                lexer.nextToken();
            }
            if (lexer.token() != MySQLToken.EOF) {
                throw new SQLSyntaxErrorException("SQL syntax error!");
            }
        }
        return stmt;
    } catch (Exception e) {
        throw new SQLSyntaxErrorException(buildErrorMsg(e, lexer, sql), e);
    }
}
Also used : MySQLDMLUpdateParser(com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDMLUpdateParser) MySQLDMLSelectParser(com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDMLSelectParser) MySQLDDLParser(com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDDLParser) MySQLDALParser(com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDALParser) SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) MySQLDMLCallParser(com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDMLCallParser) SQLStatement(com.alibaba.cobar.parser.ast.stmt.SQLStatement) MySQLDMLDeleteParser(com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDMLDeleteParser) SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) MySQLExprParser(com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLExprParser) MySQLDMLReplaceParser(com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDMLReplaceParser) MySQLMTSParser(com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLMTSParser) MySQLDMLInsertParser(com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDMLInsertParser)

Example 49 with SQLSyntaxErrorException

use of java.sql.SQLSyntaxErrorException in project liquibase by liquibase.

the class MySQLIntegrationTest method dateDefaultValue.

@Test
public void dateDefaultValue() throws Exception {
    if (getDatabase() == null) {
        return;
    }
    Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", getDatabase()).execute(new RawSqlStatement("DROP TABLE IF " + "EXISTS ad"));
    try {
        Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", getDatabase()).execute(new RawSqlStatement("CREATE TABLE ad (\n" + "ad_id int(10) unsigned NOT NULL AUTO_INCREMENT,\n" + "advertiser_id int(10) unsigned NOT NULL,\n" + "ad_type_id int(10) unsigned NOT NULL,\n" + "name varchar(155) NOT NULL DEFAULT '',\n" + "label varchar(155)NOT NULL DEFAULT '',\n" + "description text NOT NULL,\n" + "active tinyint(1) NOT NULL DEFAULT '0',\n" + "created datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n" + "updated datetime DEFAULT '0000-00-00 00:00:00',\n" + "PRIMARY KEY (ad_id),\n" + "KEY active (active)\n" + ")"));
    } catch (DatabaseException e) {
        if (e.getCause() instanceof SQLSyntaxErrorException) {
            Scope.getCurrentScope().getLog(getClass()).warning("MySQL returned DatabaseException", e);
            assumeTrue("MySQL seems to run in strict mode (no datetime literals with 0000-00-00 allowed). " + "Cannot run this test", false);
        } else {
            throw e;
        }
    }
    DatabaseSnapshot snapshot = SnapshotGeneratorFactory.getInstance().createSnapshot(CatalogAndSchema.DEFAULT, getDatabase(), new SnapshotControl(getDatabase()));
    Column createdColumn = snapshot.get(new Column().setRelation(new Table().setName("ad").setSchema(new Schema())).setName("created"));
    Object defaultValue = createdColumn.getDefaultValue();
    assertNotNull(defaultValue);
    assertEquals("0000-00-00 00:00:00", defaultValue);
}
Also used : RawSqlStatement(liquibase.statement.core.RawSqlStatement) Table(liquibase.structure.core.Table) Column(liquibase.structure.core.Column) Schema(liquibase.structure.core.Schema) CatalogAndSchema(liquibase.CatalogAndSchema) SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) DatabaseException(liquibase.exception.DatabaseException) DatabaseSnapshot(liquibase.snapshot.DatabaseSnapshot) SnapshotControl(liquibase.snapshot.SnapshotControl) Test(org.junit.Test) AbstractIntegrationTest(liquibase.dbtest.AbstractIntegrationTest)

Example 50 with SQLSyntaxErrorException

use of java.sql.SQLSyntaxErrorException in project liquibase by liquibase.

the class MariaDBIntegrationTest method dateDefaultValue.

@Test
public void dateDefaultValue() throws Exception {
    if (getDatabase() == null) {
        return;
    }
    Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", getDatabase()).execute(new RawSqlStatement("DROP TABLE IF " + "EXISTS ad"));
    try {
        Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", getDatabase()).execute(new RawSqlStatement("CREATE TABLE ad (\n" + "ad_id int(10) unsigned NOT NULL AUTO_INCREMENT,\n" + "advertiser_id int(10) unsigned NOT NULL,\n" + "ad_type_id int(10) unsigned NOT NULL,\n" + "name varchar(155) NOT NULL DEFAULT '',\n" + "label varchar(155)NOT NULL DEFAULT '',\n" + "description text NOT NULL,\n" + "active tinyint(1) NOT NULL DEFAULT '0',\n" + "created datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n" + "updated datetime DEFAULT '0000-00-00 00:00:00',\n" + "PRIMARY KEY (ad_id),\n" + "KEY active (active)\n" + ")"));
    } catch (DatabaseException e) {
        if (e.getCause() instanceof SQLSyntaxErrorException) {
            Scope.getCurrentScope().getLog(getClass()).warning("MariaDB returned DatabaseException", e);
            assumeTrue("MariaDB seems to run in strict mode (no datetime literals with 0000-00-00 allowed). " + "Cannot run this test", false);
        } else {
            throw e;
        }
    }
    DatabaseSnapshot snapshot = SnapshotGeneratorFactory.getInstance().createSnapshot(CatalogAndSchema.DEFAULT, getDatabase(), new SnapshotControl(getDatabase()));
    Column createdColumn = snapshot.get(new Column().setRelation(new Table().setName("ad").setSchema(new Schema())).setName("created"));
    Object defaultValue = createdColumn.getDefaultValue();
    assertNotNull(defaultValue);
    assertEquals("0000-00-00 00:00:00", defaultValue);
}
Also used : RawSqlStatement(liquibase.statement.core.RawSqlStatement) Table(liquibase.structure.core.Table) Column(liquibase.structure.core.Column) Schema(liquibase.structure.core.Schema) CatalogAndSchema(liquibase.CatalogAndSchema) SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) DatabaseException(liquibase.exception.DatabaseException) DatabaseSnapshot(liquibase.snapshot.DatabaseSnapshot) SnapshotControl(liquibase.snapshot.SnapshotControl) Test(org.junit.Test) AbstractIntegrationTest(liquibase.dbtest.AbstractIntegrationTest)

Aggregations

SQLSyntaxErrorException (java.sql.SQLSyntaxErrorException)55 Test (org.junit.Test)14 Test (org.testng.annotations.Test)14 BaseTest (util.BaseTest)14 DataAccessException (org.jooq.exception.DataAccessException)9 HashMap (java.util.HashMap)7 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)6 MySqlStatementParser (com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)6 SQLStatementParser (com.alibaba.druid.sql.parser.SQLStatementParser)6 TableConfig (io.mycat.config.model.TableConfig)6 SQLNonTransientException (java.sql.SQLNonTransientException)6 Expression (com.alibaba.cobar.parser.ast.expression.Expression)5 Identifier (com.alibaba.cobar.parser.ast.expression.primary.Identifier)4 SQLExprTableSource (com.alibaba.druid.sql.ast.statement.SQLExprTableSource)4 SchemaConfig (io.mycat.config.model.SchemaConfig)4 DruidShardingParseInfo (io.mycat.route.parser.druid.DruidShardingParseInfo)4 MycatSchemaStatVisitor (io.mycat.route.parser.druid.MycatSchemaStatVisitor)4 MycatStatementParser (io.mycat.route.parser.druid.MycatStatementParser)4 SQLException (java.sql.SQLException)4 DataSource (javax.sql.DataSource)4