Coverage Report - liquibase.sqlgenerator.core.SetColumnRemarksGenerator
 
Classes in this File Line Coverage Branch Coverage Complexity
SetColumnRemarksGenerator
33%
3/9
75%
3/4
1.25
 
 1  
 package liquibase.sqlgenerator.core;
 2  
 
 3  
 import liquibase.database.Database;
 4  
 import liquibase.database.core.OracleDatabase;
 5  
 import liquibase.database.core.PostgresDatabase;
 6  
 import liquibase.exception.ValidationErrors;
 7  
 import liquibase.sql.Sql;
 8  
 import liquibase.sql.UnparsedSql;
 9  
 import liquibase.sqlgenerator.SqlGenerator;
 10  
 import liquibase.sqlgenerator.SqlGeneratorChain;
 11  
 import liquibase.statement.core.SetColumnRemarksStatement;
 12  
 
 13  13
 public class SetColumnRemarksGenerator extends AbstractSqlGenerator<SetColumnRemarksStatement> {
 14  
     @Override
 15  
     public int getPriority() {
 16  1
         return PRIORITY_DEFAULT;
 17  
     }
 18  
 
 19  
     @Override
 20  
     public boolean supports(SetColumnRemarksStatement statement, Database database) {
 21  3
         return database instanceof OracleDatabase || database instanceof PostgresDatabase;
 22  
     }
 23  
 
 24  
     public ValidationErrors validate(SetColumnRemarksStatement setColumnRemarksStatement, Database database,
 25  
             SqlGeneratorChain sqlGeneratorChain) {
 26  0
         ValidationErrors validationErrors = new ValidationErrors();
 27  0
         validationErrors.checkRequiredField("tableName", setColumnRemarksStatement.getTableName());
 28  0
         validationErrors.checkRequiredField("columnName", setColumnRemarksStatement.getColumnName());
 29  0
         validationErrors.checkRequiredField("remarks", setColumnRemarksStatement.getRemarks());
 30  0
         return validationErrors;
 31  
     }
 32  
 
 33  
     public Sql[] generateSql(SetColumnRemarksStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
 34  0
         return new Sql[] { new UnparsedSql("COMMENT ON COLUMN "
 35  
                 + database.escapeTableName(statement.getSchemaName(), statement.getTableName())
 36  
                 + "."
 37  
                 + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(),
 38  
                         statement.getColumnName()) + " IS '" + database.escapeStringForDatabase(statement.getRemarks())
 39  
                 + "'") };
 40  
     }
 41  
 }