liquibase.ext.cachedb.sqlgenerator.SetNullableGeneratorCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-cache Show documentation
Show all versions of liquibase-cache Show documentation
Adds support for InterSystems Caché database
package liquibase.ext.cachedb.sqlgenerator;
import liquibase.database.Database;
import liquibase.ext.cachedb.database.CacheDatabase;
import liquibase.sql.Sql;
import liquibase.sql.UnparsedSql;
import liquibase.sqlgenerator.SqlGeneratorChain;
import liquibase.sqlgenerator.core.SetNullableGenerator;
import liquibase.statement.core.SetNullableStatement;
public class SetNullableGeneratorCache extends SetNullableGenerator {
@Override
public int getPriority() {
return PRIORITY_DATABASE;
}
@Override
public boolean supports(SetNullableStatement statement, Database database) {
return database instanceof CacheDatabase;
}
@Override
public Sql[] generateSql(SetNullableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String nullableString;
if (statement.isNullable()) {
nullableString = " NULL";
} else {
nullableString = " NOT NULL";
}
String sql = "ALTER TABLE " + database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName()) + " ALTER COLUMN " + database.escapeColumnName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName(), statement.getColumnName()) + nullableString;
return new Sql[]{new UnparsedSql(sql, getAffectedColumn(statement))};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy