本文整理汇总了Java中liquibase.statement.core.DropColumnStatement类的典型用法代码示例。如果您正苦于以下问题:Java DropColumnStatement类的具体用法?Java DropColumnStatement怎么用?Java DropColumnStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DropColumnStatement类属于liquibase.statement.core包,在下文中一共展示了DropColumnStatement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validate
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Override
public ValidationErrors validate(DropColumnStatement dropColumnStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
if (dropColumnStatement.isMultiple()) {
ValidationErrors validationErrors = new ValidationErrors();
DropColumnStatement firstColumn = dropColumnStatement.getColumns().get(0);
for (DropColumnStatement drop : dropColumnStatement.getColumns()) {
validationErrors.addAll(validateSingleColumn(drop));
if (drop.getTableName() != null && !drop.getTableName().equals(firstColumn.getTableName())) {
validationErrors.addError("All columns must be targeted at the same table");
}
if (drop.isMultiple()) {
validationErrors.addError("Nested multiple drop column statements are not supported");
}
}
return validationErrors;
} else {
return validateSingleColumn(dropColumnStatement);
}
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:21,代码来源:HiveDropColumnGenerator.java
示例2: generateStatements
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
public SqlStatement[] generateStatements(Database database) {
//todo if (database instanceof SQLiteDatabase) {
// // return special statements for SQLite databases
// return generateStatementsForSQLiteDatabase(database);
// }
List<SqlStatement> statements = new ArrayList<SqlStatement>();
String schemaName = getSchemaName() == null?database.getDefaultSchemaName():getSchemaName();
statements.add(new DropColumnStatement(schemaName, getTableName(), getColumnName()));
if (database instanceof DB2Database) {
statements.add(new ReorganizeTableStatement(schemaName, getTableName()));
}
return statements.toArray(new SqlStatement[statements.size()]);
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:DropColumnChange.java
示例3: generateSql
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(final DropColumnStatement statement, final Database database,
final SqlGeneratorChain sqlGeneratorChain) {
String schemaName = statement.getSchemaName();
if (schemaName == null) {
schemaName = database.getDefaultSchemaName();
}
final String tableName = statement.getTableName();
final String columnName = statement.getColumnName();
final boolean isGeometryColumn = GeometryColumnsUtils.isGeometryColumn(database, schemaName,
tableName, columnName);
final List<Sql> list = new ArrayList<Sql>();
if (isGeometryColumn) {
dropSpatialIndexIfExists(statement.getCatalogName(), schemaName, tableName, database, list);
final String sql = "CALL DropGeometryColumn('" + schemaName + "', '" + tableName + "', '"
+ columnName + "')";
final Column column = getAffectedColumn(statement);
final Sql dropGeometryColumn = new UnparsedSql(sql, column);
list.add(dropGeometryColumn);
} else {
list.addAll(Arrays.asList(sqlGeneratorChain.generateSql(statement, database)));
}
return list.toArray(new Sql[list.size()]);
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:26,代码来源:DropGeometryColumnGeneratorGeoDB.java
示例4: testGenerateSql
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Test(dataProvider = "generateSqlTestData")
public void testGenerateSql(final DropColumnStatement statement, final Database database,
final Sql[] expected) throws DatabaseException {
final DropGeometryColumnGeneratorGeoDB generator = new DropGeometryColumnGeneratorGeoDB();
final SqlGeneratorChain sqlGeneratorChain = mock(SqlGeneratorChain.class);
when(sqlGeneratorChain.generateSql(statement, database)).thenReturn(new Sql[0]);
final Sql[] result = generator.generateSql(statement, database, sqlGeneratorChain);
assertEquals(result.length, expected.length);
if (result.length > 0) {
for (int ii = 0; ii < result.length; ii++) {
final Sql resultSql = result[ii];
final Sql expectedSql = expected[ii];
assertEquals(resultSql.toSql(), expectedSql.toSql());
}
}
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:17,代码来源:DropGeometryColumnGeneratorGeoDBTest.java
示例5: generateMultipleColumnSql
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
private Sql[] generateMultipleColumnSql(DropColumnStatement dropColumnStatement, Database database, Map<String, String> columnsPreserved) {
if (columnsPreserved == null) {
throw new UnexpectedLiquibaseException("no columns to preserve");
}
List<Sql> result = new ArrayList<Sql>();
Map<String, String> columnsPreservedCopy = new HashMap<String, String>(columnsPreserved);
String alterTable;
List<DropColumnStatement> columns = null;
if (dropColumnStatement.isMultiple()) {
columns = dropColumnStatement.getColumns();
for (DropColumnStatement statement : columns) {
columnsPreservedCopy.remove(statement.getColumnName());
}
alterTable = "ALTER TABLE " + database.escapeTableName(columns.get(0).getCatalogName(), columns.get(0).getSchemaName(), columns.get(0).getTableName()) + " REPLACE COLUMNS (";
} else {
columnsPreservedCopy.remove(dropColumnStatement.getColumnName());
alterTable = "ALTER TABLE " + database.escapeTableName(dropColumnStatement.getCatalogName(), dropColumnStatement.getSchemaName(), dropColumnStatement.getTableName()) + " REPLACE COLUMNS (";
}
int i = 0;
for (String columnName : columnsPreservedCopy.keySet()) {
alterTable += database.escapeObjectName(columnName, Column.class) + " " + columnsPreservedCopy.get(columnName);
if (i < columnsPreservedCopy.size() - 1) {
alterTable += ",";
} else {
alterTable += ")";
}
i++;
}
if (dropColumnStatement.isMultiple()) {
result.add(new UnparsedSql(alterTable, getAffectedColumns(columns)));
} else {
result.add(new UnparsedSql(alterTable, getAffectedColumn(dropColumnStatement)));
}
return result.toArray(new Sql[result.size()]);
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:39,代码来源:HiveDropColumnGenerator.java
示例6: getAffectedColumns
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
private Column[] getAffectedColumns(List<DropColumnStatement> columns) {
List<Column> affected = new ArrayList<Column>();
for (DropColumnStatement column : columns) {
affected.add(getAffectedColumn(column));
}
return affected.toArray(new Column[affected.size()]);
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:8,代码来源:HiveDropColumnGenerator.java
示例7: testWithoutPerconaRollback
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Test
public void testWithoutPerconaRollback() throws RollbackImpossibleException {
PTOnlineSchemaChangeStatement.available = false;
SqlStatement[] statements = generateRollbackStatements();
Assert.assertEquals(1, statements.length);
Assert.assertEquals(DropColumnStatement.class, statements[0].getClass());
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:8,代码来源:PerconaAddColumnChangeTest.java
示例8: testRollbackSQL
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Test
public void testRollbackSQL() throws RollbackImpossibleException {
enableLogging();
SqlStatement[] statements = generateRollbackStatements();
Assert.assertEquals(3, statements.length);
Assert.assertEquals(CommentStatement.class, statements[0].getClass());
Assert.assertEquals("pt-online-schema-change --alter=\"DROP COLUMN new_column\" "
+ "--alter-foreign-keys-method=auto "
+ "--host=localhost --port=3306 --user=user --password=*** --execute D=testdb,t=person",
((CommentStatement)statements[0]).getText());
Assert.assertEquals(CommentStatement.class, statements[1].getClass());
Assert.assertEquals(DropColumnStatement.class, statements[2].getClass());
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:15,代码来源:PerconaAddColumnChangeTest.java
示例9: testWithoutPercona
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Test
public void testWithoutPercona() {
PTOnlineSchemaChangeStatement.available = false;
SqlStatement[] statements = generateStatements();
Assert.assertEquals(1, statements.length);
Assert.assertEquals(DropColumnStatement.class, statements[0].getClass());
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:8,代码来源:PerconaDropColumnChangeTest.java
示例10: testUpdateSQL
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Test
public void testUpdateSQL() {
enableLogging();
SqlStatement[] statements = generateStatements();
Assert.assertEquals(3, statements.length);
Assert.assertEquals(CommentStatement.class, statements[0].getClass());
Assert.assertEquals("pt-online-schema-change --alter=\"DROP COLUMN col_test\" "
+ "--alter-foreign-keys-method=auto "
+ "--host=localhost --port=3306 --user=user --password=*** --execute D=testdb,t=person",
((CommentStatement)statements[0]).getText());
Assert.assertEquals(CommentStatement.class, statements[1].getClass());
Assert.assertEquals(DropColumnStatement.class, statements[2].getClass());
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:15,代码来源:PerconaDropColumnChangeTest.java
示例11: generateSql
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
public Sql[] generateSql(DropColumnStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
if (database instanceof DB2Database) {
return new Sql[] { new UnparsedSql("ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " DROP COLUMN " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getColumnName())) };
} else if (database instanceof SybaseDatabase || database instanceof SybaseASADatabase || database instanceof FirebirdDatabase || database instanceof InformixDatabase) {
return new Sql[] { new UnparsedSql("ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " DROP " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getColumnName())) };
}
return new Sql[] { new UnparsedSql("ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " DROP COLUMN " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getColumnName())) };
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:9,代码来源:DropColumnGenerator.java
示例12: supportsTestData
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
/**
* Provides test data to {@link #testSupports(DropColumnStatement, Database, boolean)}.
*
* @return the test data.
*/
@DataProvider
public Object[][] supportsTestData() {
final DropColumnStatement statement = new DropColumnStatement(null, null, null, null);
return new Object[][] { new Object[] { statement, new DerbyDatabase(), true },
new Object[] { statement, new H2Database(), true },
new Object[] { statement, new OracleDatabase(), false }, };
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:13,代码来源:DropGeometryColumnGeneratorGeoDBTest.java
示例13: generateSql
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
public Sql[] generateSql(DropColumnStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
if (!supports(statement, database)) {
return sqlGeneratorChain.generateSql(statement, database);
}
String catalogName = statement.getCatalogName();
String schemaName = statement.getSchemaName();
if (schemaName == null) {
schemaName = database.getDefaultSchemaName();
}
String tableName = statement.getTableName();
String columnName = statement.getColumnName();
List<Sql> returnSql = new ArrayList<Sql>();
// drop both incoming and outgoing foreign key constraints before dropping column
Set<ForeignKeyConstraintMetaData> constraints = SqlGeneratorHelperHanaDB.getAllForeignKeyConstraints(database, schemaName, tableName);
SqlGeneratorHelperHanaDB.addDropForeignKeyConstraintsStatements(returnSql, database, constraints);
returnSql.add(new UnparsedSql("ALTER TABLE " +
database.escapeTableName(catalogName, schemaName, tableName) +
" DROP (" +
database.escapeColumnName(catalogName, schemaName, tableName, columnName) +
")", getAffectedColumn(statement)));
// recreate foreign key constraints
SqlGeneratorHelperHanaDB.addCreateForeignKeyConstraintsStatements(returnSql, database, constraints);
return returnSql.toArray(new Sql[returnSql.size()]);
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:31,代码来源:DropColumnGeneratorHanaDB.java
示例14: testSingleColumnDropNoSchema
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Test
public void testSingleColumnDropNoSchema() {
DropColumnStatement statement = new DropColumnStatement(null, null, "table_name", "column_name");
assertEquals("ALTER TABLE \"table_name\" DROP (\"column_name\")",
this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:8,代码来源:DropColumnGeneratorHanaDBTest.java
示例15: testSingleColumnDropWithSchema
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Test
public void testSingleColumnDropWithSchema() {
DropColumnStatement statement = new DropColumnStatement(null, "schema_name", "table_name", "column_name");
assertEquals("ALTER TABLE \"schema_name\".\"table_name\" DROP (\"column_name\")",
this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:8,代码来源:DropColumnGeneratorHanaDBTest.java
示例16: supports
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Override
public boolean supports(DropColumnStatement dropColumnStatement, Database database) {
return database instanceof HiveDatabase && super.supports(dropColumnStatement, database);
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:5,代码来源:HiveDropColumnGenerator.java
示例17: validateSingleColumn
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
private ValidationErrors validateSingleColumn(DropColumnStatement dropColumnStatement) {
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("tableName", dropColumnStatement.getTableName());
validationErrors.checkRequiredField("columnName", dropColumnStatement.getColumnName());
return validationErrors;
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:7,代码来源:HiveDropColumnGenerator.java
示例18: generateSql
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(DropColumnStatement dropColumnStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
Map<String, String> columnsPreserved = null;
columnsPreserved = columnsMap((HiveDatabase) database, dropColumnStatement);
return generateMultipleColumnSql(dropColumnStatement, database, columnsPreserved);
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:7,代码来源:HiveDropColumnGenerator.java
示例19: getAffectedColumn
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
private Column getAffectedColumn(DropColumnStatement statement) {
return new Column().setName(statement.getColumnName()).setRelation(new Table().setName(statement.getTableName()).setSchema(statement.getCatalogName(), statement.getSchemaName()));
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:4,代码来源:HiveDropColumnGenerator.java
示例20: validate
import liquibase.statement.core.DropColumnStatement; //导入依赖的package包/类
public ValidationErrors validate(DropColumnStatement dropColumnStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("tableName", dropColumnStatement.getTableName());
validationErrors.checkRequiredField("columnName", dropColumnStatement.getColumnName());
return validationErrors;
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:7,代码来源:DropColumnGenerator.java
注:本文中的liquibase.statement.core.DropColumnStatement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论