Coverage Report - liquibase.sqlgenerator.core.DropColumnGenerator
 
Classes in this File Line Coverage Branch Coverage Complexity
DropColumnGenerator
50%
5/10
0%
0/10
4.5
 
 1  
 package liquibase.sqlgenerator.core;
 2  
 
 3  
 import liquibase.database.Database;
 4  
 import liquibase.database.core.DB2Database;
 5  
 import liquibase.database.core.FirebirdDatabase;
 6  
 import liquibase.database.core.InformixDatabase;
 7  
 import liquibase.database.core.SybaseASADatabase;
 8  
 import liquibase.database.core.SybaseDatabase;
 9  
 import liquibase.exception.ValidationErrors;
 10  
 import liquibase.sql.Sql;
 11  
 import liquibase.sql.UnparsedSql;
 12  
 import liquibase.sqlgenerator.SqlGeneratorChain;
 13  
 import liquibase.statement.core.DropColumnStatement;
 14  
 
 15  25
 public class DropColumnGenerator extends AbstractSqlGenerator<DropColumnStatement> {
 16  
 
 17  
     @Override
 18  
     public ValidationErrors validate(DropColumnStatement dropColumnStatement, Database database,
 19  
             SqlGeneratorChain sqlGeneratorChain) {
 20  15
         ValidationErrors validationErrors = new ValidationErrors();
 21  15
         validationErrors.checkRequiredField("tableName", dropColumnStatement.getTableName());
 22  15
         validationErrors.checkRequiredField("columnName", dropColumnStatement.getColumnName());
 23  15
         return validationErrors;
 24  
     }
 25  
 
 26  
     @Override
 27  
     public Sql[] generateSql(DropColumnStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
 28  0
         if (database instanceof DB2Database) {
 29  0
             return new Sql[] { new UnparsedSql("ALTER TABLE "
 30  
                     + database.escapeTableName(statement.getSchemaName(), statement.getTableName())
 31  
                     + " DROP COLUMN "
 32  
                     + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(),
 33  
                             statement.getColumnName())) };
 34  0
         } else if (database instanceof SybaseDatabase || database instanceof SybaseASADatabase
 35  
                 || database instanceof FirebirdDatabase || database instanceof InformixDatabase) {
 36  0
             return new Sql[] { new UnparsedSql("ALTER TABLE "
 37  
                     + database.escapeTableName(statement.getSchemaName(), statement.getTableName())
 38  
                     + " DROP "
 39  
                     + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(),
 40  
                             statement.getColumnName())) };
 41  
         }
 42  0
         return new Sql[] { new UnparsedSql("ALTER TABLE "
 43  
                 + database.escapeTableName(statement.getSchemaName(), statement.getTableName())
 44  
                 + " DROP COLUMN "
 45  
                 + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(),
 46  
                         statement.getColumnName())) };
 47  
     }
 48  
 }