use of liquibase.statement.SqlStatement in project liquibase by liquibase.
the class AddPrimaryKeyChange method generateStatements.
@Override
public SqlStatement[] generateStatements(Database database) {
AddPrimaryKeyStatement statement = new AddPrimaryKeyStatement(getCatalogName(), getSchemaName(), getTableName(), getColumnNames(), getConstraintName());
statement.setTablespace(getTablespace());
statement.setClustered(getClustered());
statement.setForIndexName(getForIndexName());
statement.setForIndexSchemaName(getForIndexSchemaName());
statement.setForIndexCatalogName(getForIndexCatalogName());
if (database instanceof DB2Database) {
return new SqlStatement[] { statement, new ReorganizeTableStatement(getCatalogName(), getSchemaName(), getTableName()) };
//todo } else if (database instanceof SQLiteDatabase) {
// // return special statements for SQLite databases
// return generateStatementsForSQLiteDatabase(database);
}
return new SqlStatement[] { statement };
}
use of liquibase.statement.SqlStatement in project liquibase by liquibase.
the class CreateProcedureChange method generateStatements.
protected SqlStatement[] generateStatements(String logicText, String endDelimiter, Database database) {
CreateProcedureStatement statement = new CreateProcedureStatement(getCatalogName(), getSchemaName(), getProcedureName(), logicText, endDelimiter);
statement.setReplaceIfExists(getReplaceIfExists());
return new SqlStatement[] { statement };
}
use of liquibase.statement.SqlStatement in project liquibase by liquibase.
the class AbstractJdbcDatabaseTest method executeRollbackStatements_WithStatementsOverload_ShouldNotIncludeAppendTextFromApplyToRollbackFalseVisitor.
@Test
public void executeRollbackStatements_WithStatementsOverload_ShouldNotIncludeAppendTextFromApplyToRollbackFalseVisitor() throws Exception {
Database database = getDatabase();
final MockExecutor mockExecutor = new MockExecutor();
ExecutorService.getInstance().setExecutor(database, mockExecutor);
final List<SqlVisitor> sqlVisitors = new ArrayList<SqlVisitor>();
final SqlStatement dropTableStatement = new DropTableStatement(null, null, "test_table", false);
final AppendSqlVisitor appendSqlVisitor = new AppendSqlVisitor();
appendSqlVisitor.setApplyToRollback(false);
appendSqlVisitor.setValue(" SHOULD NOT BE APPENDED");
sqlVisitors.add(appendSqlVisitor);
database.executeRollbackStatements(new SqlStatement[] { dropTableStatement }, sqlVisitors);
assertEquals("DROP TABLE test_table;", mockExecutor.getRanSql().trim());
}
use of liquibase.statement.SqlStatement in project liquibase by liquibase.
the class AbstractSQLChangeTest method generateStatements_convertsEndingsOnSqlServer.
@Test
public void generateStatements_convertsEndingsOnSqlServer() {
ExampleAbstractSQLChange change = new ExampleAbstractSQLChange("LINE 1;\n--a comment\nLINE 2;\nLINE 3;");
change.setSplitStatements(false);
change.setStripComments(true);
SqlStatement[] statements = change.generateStatements(new MSSQLDatabase());
assertEquals(1, statements.length);
assertEquals("LINE 1;\r\n\r\nLINE 2;\r\nLINE 3;", ((RawSqlStatement) statements[0]).getSql());
}
use of liquibase.statement.SqlStatement in project liquibase by liquibase.
the class AddColumnChangeTest method generateStatements_DB2_multipleColumns_single_reorg.
@Test
public void generateStatements_DB2_multipleColumns_single_reorg() {
AddColumnChange change = new AddColumnChange();
AddColumnConfig column1 = new AddColumnConfig();
column1.setName("column1");
column1.setType("INT");
change.addColumn(column1);
AddColumnConfig column2 = new AddColumnConfig();
column2.setName("column2");
column2.setType("INT");
change.addColumn(column2);
SqlStatement[] statements = change.generateStatements(new DB2Database());
Assert.assertEquals(2, statements.length);
Assert.assertTrue(statements[0] instanceof AddColumnStatement);
AddColumnStatement stmt = (AddColumnStatement) statements[0];
Assert.assertTrue(stmt.isMultiple());
Assert.assertEquals(2, stmt.getColumns().size());
Assert.assertTrue(statements[1] instanceof ReorganizeTableStatement);
}
Aggregations