Class GeneratedColumnSqlGenerator

  • All Implemented Interfaces:
    liquibase.servicelocator.PrioritizedService, liquibase.sqlgenerator.SqlGenerator<liquibase.statement.core.AddColumnStatement>

    public class GeneratedColumnSqlGenerator
    extends liquibase.sqlgenerator.core.AddColumnGenerator
    A SqlGenerator implementation that supports GeneratedColumnStatements. It generates the SQL required to add a column whose values are generated from a property of a JSON file stored in one of the table columns or a function which is used to create a generated column.
    Stefan Guilhen
    • Field Summary

      • Fields inherited from interface liquibase.servicelocator.PrioritizedService

      • Fields inherited from interface liquibase.sqlgenerator.SqlGenerator

    • Constructor Detail

      • GeneratedColumnSqlGenerator

        public GeneratedColumnSqlGenerator()
    • Method Detail

      • getPriority

        public int getPriority()
        Override the priority. This is needed because GeneratedColumnStatement is a subtype of AddColumnStatement and is thus a match for the standard column generators. By increasing the priority we ensure this is processed before the other generators.
        Specified by:
        getPriority in interface liquibase.servicelocator.PrioritizedService
        Specified by:
        getPriority in interface liquibase.sqlgenerator.SqlGenerator<liquibase.statement.core.AddColumnStatement>
        getPriority in class liquibase.sqlgenerator.core.AbstractSqlGenerator<liquibase.statement.core.AddColumnStatement>
        this generator's priority.
      • supports

        public boolean supports​(liquibase.statement.core.AddColumnStatement statement,
                                liquibase.database.Database database)
        Implement supports(AddColumnStatement, Database) to return true only if the statement type is an instance of GeneratedColumnStatement.

        This is needed because this generator is a sub-class of AddColumnGenerator and is thus registered as being able to handle statements of type AddColumnStatement. Due to the increased priority, this generator ends up being selected to handle standard addColumn changes, which is not desirable. By returning true only when the statement is a GeneratedColumnStatement we ensure this implementation is selected only when a generated column is being added, allowing liquibase to continue iterating through the chain of generators in order to select the right generator to handle the standard addColumn changes.
        Specified by:
        supports in interface liquibase.sqlgenerator.SqlGenerator<liquibase.statement.core.AddColumnStatement>
        supports in class liquibase.sqlgenerator.core.AbstractSqlGenerator<liquibase.statement.core.AddColumnStatement>
        statement - the SqlStatement to be processed.
        database - a reference to the database.
        true if an only if the statement is a GeneratedColumnStatement; false otherwise.
      • generateSingleColumn

        protected liquibase.sql.Sql[] generateSingleColumn​(liquibase.statement.core.AddColumnStatement statement,
                                                           liquibase.database.Database database)
        generateSingleColumn in class liquibase.sqlgenerator.core.AddColumnGenerator