Coverage Report - liquibase.sqlgenerator.core.DropTableGenerator
 
Classes in this File Line Coverage Branch Coverage Complexity
DropTableGenerator
30%
4/13
0%
0/6
2.5
 
 1  
 package liquibase.sqlgenerator.core;
 2  
 
 3  
 import liquibase.database.Database;
 4  
 import liquibase.database.core.OracleDatabase;
 5  
 import liquibase.exception.ValidationErrors;
 6  
 import liquibase.logging.LogFactory;
 7  
 import liquibase.sql.Sql;
 8  
 import liquibase.sql.UnparsedSql;
 9  
 import liquibase.sqlgenerator.SqlGeneratorChain;
 10  
 import liquibase.statement.core.DropTableStatement;
 11  
 
 12  25
 public class DropTableGenerator extends AbstractSqlGenerator<DropTableStatement> {
 13  
 
 14  
     @Override
 15  
     public ValidationErrors validate(DropTableStatement dropTableStatement, Database database,
 16  
             SqlGeneratorChain sqlGeneratorChain) {
 17  15
         ValidationErrors validationErrors = new ValidationErrors();
 18  15
         validationErrors.checkRequiredField("tableName", dropTableStatement.getTableName());
 19  15
         return validationErrors;
 20  
     }
 21  
 
 22  
     @Override
 23  
     public Sql[] generateSql(DropTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
 24  0
         StringBuffer buffer = new StringBuffer();
 25  0
         buffer.append("DROP TABLE ").append(
 26  
                 database.escapeTableName(statement.getSchemaName(), statement.getTableName()));
 27  0
         if (statement.isCascadeConstraints()) {
 28  0
             if (database.supportsDropTableCascadeConstraints()) {
 29  0
                 LogFactory.getLogger().warning("Database does not support drop with cascade");
 30  0
             } else if (database instanceof OracleDatabase) {
 31  0
                 buffer.append(" CASCADE CONSTRAINTS");
 32  
             } else {
 33  0
                 buffer.append(" CASCADE");
 34  
             }
 35  
         }
 36  
 
 37  0
         return new Sql[] { new UnparsedSql(buffer.toString()) };
 38  
     }
 39  
 }