Search in sources :

Example 91 with ValidationErrors

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;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors) MockDatabase(liquibase.database.core.MockDatabase)

Example 92 with 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;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Example 93 with 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);
    }
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors) AddColumnStatement(liquibase.statement.core.AddColumnStatement)

Example 94 with ValidationErrors

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;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Example 95 with 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;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Aggregations

ValidationErrors (liquibase.exception.ValidationErrors)105 Test (org.junit.Test)14 MockDatabase (liquibase.database.core.MockDatabase)11 Database (liquibase.database.Database)7 MockSqlStatement (liquibase.statement.core.MockSqlStatement)6 TreeSet (java.util.TreeSet)5 SqlStatement (liquibase.statement.SqlStatement)5 Change (liquibase.change.Change)4 ChangeFactory (liquibase.change.ChangeFactory)4 ChangeParameterMetaData (liquibase.change.ChangeParameterMetaData)4 UnexpectedLiquibaseException (liquibase.exception.UnexpectedLiquibaseException)4 ChangeMetaData (liquibase.change.ChangeMetaData)3 MockSqlGeneratorChain (liquibase.sqlgenerator.MockSqlGeneratorChain)3 AbstractVerifyTest (liquibase.verify.AbstractVerifyTest)3 ArrayList (java.util.ArrayList)2 CreateTableChange (liquibase.change.core.CreateTableChange)2 DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)2 RanChangeSet (liquibase.changelog.RanChangeSet)2 DatabaseConnection (liquibase.database.DatabaseConnection)2 Db2zDatabase (liquibase.database.core.Db2zDatabase)2