use of liquibase.exception.ValidationErrors in project liquibase by liquibase.
the class AddPrimaryKeyGenerator method validate.
@Override
public ValidationErrors validate(AddPrimaryKeyStatement addPrimaryKeyStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("columnNames", addPrimaryKeyStatement.getColumnNames());
validationErrors.checkRequiredField("tableName", addPrimaryKeyStatement.getTableName());
if (addPrimaryKeyStatement.isClustered() != null) {
if (database instanceof PostgresDatabase) {
if (addPrimaryKeyStatement.isClustered() && addPrimaryKeyStatement.getConstraintName() == null) {
validationErrors.addError("Postgresql requires constraintName on addPrimaryKey when clustered=true");
}
} else if (database instanceof MSSQLDatabase || database instanceof MockDatabase) {
// clustered is fine
} else if (addPrimaryKeyStatement.isClustered()) {
validationErrors.addError("Cannot specify clustered=true on " + database.getShortName());
}
}
if (!((database instanceof OracleDatabase) || (database instanceof AbstractDb2Database))) {
validationErrors.checkDisallowedField("forIndexName", addPrimaryKeyStatement.getForIndexName(), database);
}
return validationErrors;
}
use of liquibase.exception.ValidationErrors in project liquibase by liquibase.
the class AddAutoIncrementGenerator method validate.
@Override
public ValidationErrors validate(AddAutoIncrementStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("columnName", statement.getColumnName());
validationErrors.checkRequiredField("tableName", statement.getTableName());
validationErrors.checkRequiredField("columnDataType", statement.getColumnDataType());
return validationErrors;
}
use of liquibase.exception.ValidationErrors in project liquibase by liquibase.
the class AddColumnGenerator method validate.
@Override
public ValidationErrors validate(AddColumnStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
if (statement.isMultiple()) {
ValidationErrors validationErrors = new ValidationErrors();
AddColumnStatement firstColumn = statement.getColumns().get(0);
for (AddColumnStatement column : statement.getColumns()) {
validationErrors.addAll(validateSingleColumn(column, database));
if ((firstColumn.getTableName() != null) && !firstColumn.getTableName().equals(column.getTableName())) {
validationErrors.addError("All columns must be targeted at the same table");
}
if (column.isMultiple()) {
validationErrors.addError("Nested multiple add column statements are not supported");
}
}
return validationErrors;
} else {
return validateSingleColumn(statement, database);
}
}
use of liquibase.exception.ValidationErrors in project liquibase by liquibase.
the class DeleteGenerator method validate.
@Override
public ValidationErrors validate(DeleteStatement deleteStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("tableName", deleteStatement.getTableName());
if ((deleteStatement.getWhereParameters() != null) && !deleteStatement.getWhereParameters().isEmpty() && (deleteStatement.getWhere() == null)) {
validationErrors.addError("whereParams set but no whereClause");
}
return validationErrors;
}
use of liquibase.exception.ValidationErrors in project liquibase by liquibase.
the class DropDefaultValueGenerator method validate.
@Override
public ValidationErrors validate(DropDefaultValueStatement dropDefaultValueStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("tableName", dropDefaultValueStatement.getTableName());
validationErrors.checkRequiredField("columnName", dropDefaultValueStatement.getColumnName());
if (database instanceof InformixDatabase) {
validationErrors.checkRequiredField("columnDataType", dropDefaultValueStatement.getColumnDataType());
}
return validationErrors;
}
Aggregations