本文整理汇总了Java中liquibase.database.Database.escapeObjectName方法的典型用法代码示例。如果您正苦于以下问题:Java Database.escapeObjectName方法的具体用法?Java Database.escapeObjectName怎么用?Java Database.escapeObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类liquibase.database.Database
的用法示例。
在下文中一共展示了Database.escapeObjectName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSql
import liquibase.database.Database; //导入方法依赖的package包/类
@Override
public Sql[] generateSql(TagDatabaseStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String catalogName = database.getLiquibaseCatalogName();
String schemaName = database.getDefaultSchemaName();
String tableName = database.getDatabaseChangeLogTableName();
String tableNameEscaped = database.escapeObjectName(tableName, Table.class);
String dateColumnNameEscaped = database.escapeObjectName("DATEEXECUTED", Column.class);
String tagColumnNameEscaped = database.escapeObjectName("TAG", Column.class);
String tempTable = UUID.randomUUID().toString().replaceAll("-", "");
CreateTableAsSelectStatement createTableAsSelectStatement = new CreateTableAsSelectStatement(catalogName, schemaName, tableName, tempTable)
.addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "TAG", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
.setWhereCondition(tableNameEscaped + "." + dateColumnNameEscaped + " NOT IN (SELECT MAX(" + tableNameEscaped + "." + dateColumnNameEscaped + ") " +
"FROM " + tableNameEscaped + ")");
InsertAsSelectStatement insertAsSelectStatement = new InsertAsSelectStatement(catalogName, schemaName, tableName, tempTable)
.addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "'" + statement.getTag() + "'", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
.setWhereCondition(tableNameEscaped + "." + dateColumnNameEscaped + " IN (SELECT MAX(" + tableNameEscaped + "." + dateColumnNameEscaped + ") FROM " + tableNameEscaped + ") AND ("
+ tableNameEscaped + "." + tagColumnNameEscaped + " IS NULL OR " + tableNameEscaped + "." + tagColumnNameEscaped + " != ?)").addWhereParameters(statement.getTag());
return CustomSqlGenerator.generateSql(database,
createTableAsSelectStatement,
insertAsSelectStatement,
new DropTableStatement(catalogName, schemaName, tableName, false),
new RenameTableStatement(catalogName, schemaName, tempTable, tableName));
}
示例2: generateMultipleColumnSql
import liquibase.database.Database; //导入方法依赖的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()]);
}
示例3: generateSql
import liquibase.database.Database; //导入方法依赖的package包/类
@Override
public Sql[] generateSql(RenameTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String sql = "ALTER TABLE " + database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(),
statement.getOldTableName()) + " RENAME TO " + database.escapeObjectName(statement.getNewTableName(), Table.class);
return new Sql[]{
new UnparsedSql(sql,
fetchAffectedOldTable(statement),
fetchAffectedNewTable(statement)
)
};
}
示例4: generateSql
import liquibase.database.Database; //导入方法依赖的package包/类
@Override
public Sql[] generateSql(TagDatabaseStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String catalogName = database.getLiquibaseCatalogName();
String schemaName = database.getDefaultSchemaName();
String tableName = database.getDatabaseChangeLogTableName();
String tableNameEscaped = database.escapeTableName(catalogName, schemaName, tableName);
String dateColumnNameEscaped = database.escapeObjectName("DATEEXECUTED", Column.class);
String tagColumnNameEscaped = database.escapeObjectName("TAG", Column.class);
String tmpTable = UUID.randomUUID().toString().replaceAll("-", "");
CreateTableAsSelectStatement createTableAsSelectStatement = new CreateTableAsSelectStatement(catalogName, schemaName, tableName, tmpTable)
.addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "TAG", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
.setWhereCondition(dateColumnNameEscaped + " != (SELECT MAX(" + dateColumnNameEscaped + ") " +
"FROM " + tableNameEscaped + ")");
InsertAsSelectStatement insertAsSelectStatement = new InsertAsSelectStatement(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogTableName(), tmpTable)
.addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "'" + statement.getTag() + "'", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
.setWhereCondition(dateColumnNameEscaped + " = (SELECT MAX(" + dateColumnNameEscaped + ") FROM " + tableNameEscaped + ") AND ("
+ tagColumnNameEscaped + " IS NULL OR " + tagColumnNameEscaped + " != ?)")
.addWhereParameters(statement.getTag());
return CustomSqlGenerator.generateSql(database,
UserSessionSettings.syncDdlStart(),
createTableAsSelectStatement,
insertAsSelectStatement,
new DropTableStatement(catalogName, schemaName, tableName, false),
new RenameTableStatement(catalogName, schemaName, tmpTable, tableName),
UserSessionSettings.syncDdlStop());
}