Coverage Report - liquibase.sqlgenerator.core.AddAutoIncrementGeneratorHsqlH2
 
Classes in this File Line Coverage Branch Coverage Complexity
AddAutoIncrementGeneratorHsqlH2
75%
3/4
100%
4/4
1.333
 
 1  
 package liquibase.sqlgenerator.core;
 2  
 
 3  
 import liquibase.database.Database;
 4  
 import liquibase.database.core.H2Database;
 5  
 import liquibase.database.core.HsqlDatabase;
 6  
 import liquibase.database.structure.Column;
 7  
 import liquibase.database.structure.Table;
 8  
 import liquibase.sql.Sql;
 9  
 import liquibase.sql.UnparsedSql;
 10  
 import liquibase.sqlgenerator.SqlGeneratorChain;
 11  
 import liquibase.statement.core.AddAutoIncrementStatement;
 12  
 
 13  77
 public class AddAutoIncrementGeneratorHsqlH2 extends AddAutoIncrementGenerator {
 14  
 
 15  
     @Override
 16  
     public int getPriority() {
 17  1
         return PRIORITY_DATABASE;
 18  
     }
 19  
 
 20  
     @Override
 21  
     public boolean supports(AddAutoIncrementStatement statement, Database database) {
 22  61
         return database instanceof HsqlDatabase || database instanceof H2Database;
 23  
     }
 24  
 
 25  
     @Override
 26  
     public Sql[] generateSql(AddAutoIncrementStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
 27  0
         return new Sql[] { new UnparsedSql("ALTER TABLE "
 28  
                 + database.escapeTableName(statement.getSchemaName(), statement.getTableName())
 29  
                 + " ALTER COLUMN "
 30  
                 + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(),
 31  
                         statement.getColumnName()) + " " + statement.getColumnDataType()
 32  
                 + " GENERATED BY DEFAULT AS IDENTITY IDENTITY", new Column().setTable(
 33  
                 new Table(statement.getTableName()).setSchema(statement.getSchemaName())).setName(
 34  
                 statement.getColumnName())) };
 35  
     }
 36  
 }