Package liquibase.change
Class AbstractSQLChange
java.lang.Object
liquibase.AbstractExtensibleObject
liquibase.plugin.AbstractPlugin
liquibase.change.AbstractChange
liquibase.change.AbstractSQLChange
- All Implemented Interfaces:
Cloneable,Change,DbmsTargetedChange,ExtensibleObject,Plugin,LiquibaseSerializable
- Direct Known Subclasses:
RawSQLChange,SQLFileChange
A common parent for all raw SQL related changes regardless of where the sql was sourced from.
Implements the necessary logic to choose how the SQL string should be parsed to generate the statements.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface liquibase.serializer.LiquibaseSerializable
LiquibaseSerializable.SerializationType -
Field Summary
FieldsFields inherited from class liquibase.change.AbstractChange
NODENAME_COLUMNFields inherited from interface liquibase.change.Change
EMPTY_CHANGE, SHOULD_EXECUTEFields inherited from interface liquibase.serializer.LiquibaseSerializable
GENERIC_CHANGELOG_EXTENSION_NAMESPACE, GENERIC_SNAPSHOT_EXTENSION_NAMESPACE, STANDARD_CHANGELOG_NAMESPACE, STANDARD_SNAPSHOT_NAMESPACEFields inherited from interface liquibase.plugin.Plugin
PRIORITY_DATABASE, PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckStatus(Database database) Validate that this change executed successfully against the given database.Calculates the checksum based on the contained SQL.booleangenerateRollbackStatementsVolatile(Database database) Implementation delegates logic to theSqlGenerator.generateRollbackStatementsIsVolatile(Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database)If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.generateStatements(Database database) Generates one or more SqlStatements depending on how the SQL should be parsed.booleangenerateStatementsVolatile(Database database) Implementation delegates logic to theSqlGenerator.generateStatementsIsVolatile(Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database).getDbms()Set the end delimiter used to split statements.getSql()Return the raw SQL managed by this ChangeDeprecated.Return if the SQL should be split into multiple statements before passing it to the database.booleanDeprecated.To be removed when splitStatements is changed to be Boolean typeReturn if comments should be stripped from the SQL before passing it to the database.booleanprotected StringnormalizeLineEndings(String string) voidvoidsetEndDelimiter(String endDelimiter) Sets the end delimiter for splitting SQL statements.voidsetIgnoreOriginalSplitStatements(Boolean ignoreOriginalSplitStatements) Deprecated.voidsetOriginalSplitStatements(Boolean originalSplitStatements) Deprecated.voidsetSplitStatements(Boolean splitStatements) Set whether SQL should be split into multiple statements.voidSet the raw SQL managed by this Change.voidsetStripComments(Boolean stripComments) Return true if comments should be stripped from the SQL before passing it to the database.voidsetStripComments(Boolean stripComments, boolean usedDefaultValue) booleanImplementation delegates logic to theSqlGenerator.supports(liquibase.statement.SqlStatement, liquibase.database.Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database).Implementation checks the ChangeParameterMetaData for declared required fields and also delegates logic to theSqlGenerator.validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database).Implementation delegates logic to theSqlGenerator.warn(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database).Methods inherited from class liquibase.change.AbstractChange
createAlternateParameterNames, createChangeMetaData, createChangeParameterMetadata, createDescriptionMetaData, createEmptyColumnConfig, createExampleValueMetaData, createInverses, createMustEqualExistingMetaData, createRequiredDatabasesMetaData, createSerializationTypeMetaData, createSinceMetaData, createSupportedDatabasesMetaData, customLoadLogic, equals, finishInitialization, generateRollbackStatements, getAffectedDatabaseObjects, getChangeSet, getDescription, getExcludedFieldFilters, getResourceAccessor, getSerializableFieldNamespace, getSerializableFields, getSerializableFieldType, getSerializableFieldValue, getSerializedObjectName, getSerializedObjectNamespace, hashCode, isInvalidProperty, load, modify, serialize, serializeValue, setChangeSet, setResourceAccessor, shouldExecuteChange, supportsRollback, toStringMethods inherited from class liquibase.AbstractExtensibleObject
clone, describe, get, get, get, getAttributes, getFieldValue, getObjectMetaData, getValuePath, has, setMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface liquibase.change.Change
getConfirmationMessage, shouldRunOnOsMethods inherited from interface liquibase.ExtensibleObject
clone, describe, get, get, getAttributes, getObjectMetaData, getValuePath, has, set
-
Field Details
-
encoding
-
-
Constructor Details
-
AbstractSQLChange
protected AbstractSQLChange()
-
-
Method Details
-
setOriginalSplitStatements
Deprecated. -
setIgnoreOriginalSplitStatements
Deprecated.isOriginalSplitStatements is used by checksums v8 calculator only to define splitStatements behavior -
isIgnoreOriginalSplitStatements
Deprecated. -
openSqlStream
- Throws:
IOException
-
getDbms
- Specified by:
getDbmsin interfaceDbmsTargetedChange- Returns:
- A comma separated list of dbms' that this change will be run for. Will run for all dbms' if empty or null.
-
setDbms
- Specified by:
setDbmsin interfaceDbmsTargetedChange
-
supports
Implementation delegates logic to theSqlGenerator.supports(liquibase.statement.SqlStatement, liquibase.database.Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database). If no or null SqlStatements are returned by generateStatements then this method returns true. IfAbstractChange.generateStatementsVolatile(liquibase.database.Database)returns true, we cannot call generateStatements and so assume true.- Specified by:
supportsin interfaceChange- Overrides:
supportsin classAbstractChange- Parameters:
database-- Returns:
- always true (in AbstractSQLChange)
-
warn
Description copied from class:AbstractChangeImplementation delegates logic to theSqlGenerator.warn(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database). If a generated statement is not supported for the given database, no warning will be added since that is a validation error. If no or null SqlStatements are returned by generateStatements then this method returns no warnings.- Specified by:
warnin interfaceChange- Overrides:
warnin classAbstractChange
-
validate
Description copied from class:AbstractChangeImplementation checks the ChangeParameterMetaData for declared required fields and also delegates logic to theSqlGenerator.validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database). If no or null SqlStatements are returned by generateStatements then this method returns no errors. If there are no parameters than this method returns no errors- Specified by:
validatein interfaceChange- Overrides:
validatein classAbstractChange
-
isStripComments
Return if comments should be stripped from the SQL before passing it to the database. This will always return a non-null value and should be a boolean rather than a Boolean, but that breaks the Bean Standard. -
setStripComments
Return true if comments should be stripped from the SQL before passing it to the database. Passing null sets stripComments to the default value (false). -
setStripComments
-
isSplitStatements
Return if the SQL should be split into multiple statements before passing it to the database. By default, statements are split around ";" and "go" delimiters. This will always return a non-null value and should be a boolean rather than a Boolean, but that breaks the Bean Standard. -
setSplitStatements
Set whether SQL should be split into multiple statements. Passing null sets stripComments to the default value (true). -
isSplitStatementsSet
Deprecated.To be removed when splitStatements is changed to be Boolean type- Returns:
-
isStripCommentsUsedDefaultValue
public boolean isStripCommentsUsedDefaultValue() -
getSql
Return the raw SQL managed by this Change -
setSql
Set the raw SQL managed by this Change. The passed sql is trimmed and set to null if an empty string is passed. -
getEndDelimiter
Set the end delimiter used to split statements. Will return null if the default delimiter should be used.- See Also:
-
splitStatements
-
setEndDelimiter
Sets the end delimiter for splitting SQL statements. Set tonullto use the default delimiter.- Parameters:
endDelimiter- the end delimiter to set
-
generateCheckSum
Calculates the checksum based on the contained SQL.- Specified by:
generateCheckSumin interfaceChange- Overrides:
generateCheckSumin classAbstractChange- See Also:
-
generateStatements
Generates one or more SqlStatements depending on how the SQL should be parsed. If split statements is set to true then the SQL is split and each command is made into a separate SqlStatement. If stripping comments is true then any comments are removed before the splitting is executed. The set SQL is passed through theConnection.nativeSQL(java.lang.String)method if a connection is available.- Specified by:
generateStatementsin interfaceChange
-
generateStatementsVolatile
Description copied from class:AbstractChangeImplementation delegates logic to theSqlGenerator.generateStatementsIsVolatile(Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database). If zero or null SqlStatements are returned by generateStatements then this method returns false.- Specified by:
generateStatementsVolatilein interfaceChange- Overrides:
generateStatementsVolatilein classAbstractChange
-
generateRollbackStatementsVolatile
Description copied from class:AbstractChangeImplementation delegates logic to theSqlGenerator.generateRollbackStatementsIsVolatile(Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database)If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.- Specified by:
generateRollbackStatementsVolatilein interfaceChange- Overrides:
generateRollbackStatementsVolatilein classAbstractChange
-
checkStatus
Description copied from interface:ChangeValidate that this change executed successfully against the given database. This will check that the update completed at a high level plus check details of the change. For example, a change to add a column will check that the column exists plus data type, default values, etc.- Specified by:
checkStatusin interfaceChange- Overrides:
checkStatusin classAbstractChange
-
normalizeLineEndings
-