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 classes/interfaces inherited from interface liquibase.serializer.LiquibaseSerializable
LiquibaseSerializable.SerializationType
-
Field Summary
Fields inherited from class liquibase.change.AbstractChange
NODENAME_COLUMN
Fields inherited from interface liquibase.change.Change
EMPTY_CHANGE, SHOULD_EXECUTE
Fields inherited from interface liquibase.serializer.LiquibaseSerializable
GENERIC_CHANGELOG_EXTENSION_NAMESPACE, GENERIC_SNAPSHOT_EXTENSION_NAMESPACE, STANDARD_CHANGELOG_NAMESPACE, STANDARD_SNAPSHOT_NAMESPACE
Fields inherited from interface liquibase.plugin.Plugin
PRIORITY_DATABASE, PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED
-
Constructor Summary
-
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.boolean
generateRollbackStatementsVolatile
(Database database) Implementation delegates logic to theSqlGenerator.generateRollbackStatementsIsVolatile(Database)
method on theSqlStatement
objects 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.boolean
generateStatementsVolatile
(Database database) Implementation delegates logic to theSqlGenerator.generateStatementsIsVolatile(Database)
method on theSqlStatement
objects 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.boolean
Deprecated.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.protected String
normalizeLineEndings
(String string) void
void
setEndDelimiter
(String endDelimiter) Sets the end delimiter for splitting SQL statements.void
setIgnoreOriginalSplitStatements
(Boolean ignoreOriginalSplitStatements) Deprecated.void
setOriginalSplitStatements
(Boolean originalSplitStatements) Deprecated.void
setSplitStatements
(Boolean splitStatements) Set whether SQL should be split into multiple statements.void
Set the raw SQL managed by this Change.void
setStripComments
(Boolean stripComments) Return true if comments should be stripped from the SQL before passing it to the database.void
setStripComments
(Boolean stripComments, boolean usedDefaultValue) boolean
Implementation delegates logic to theSqlGenerator.supports(liquibase.statement.SqlStatement, liquibase.database.Database)
method on theSqlStatement
objects 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 theSqlStatement
objects returned byChange.generateStatements(liquibase.database.Database)
.Implementation delegates logic to theSqlGenerator.warn(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)
method on theSqlStatement
objects 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, toString
Methods inherited from class liquibase.AbstractExtensibleObject
clone, describe, get, get, get, getAttributes, getFieldValue, getObjectMetaData, getValuePath, has, set
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface liquibase.change.Change
getConfirmationMessage
Methods 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:
getDbms
in 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:
setDbms
in interfaceDbmsTargetedChange
-
supports
Implementation delegates logic to theSqlGenerator.supports(liquibase.statement.SqlStatement, liquibase.database.Database)
method on theSqlStatement
objects 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:
supports
in interfaceChange
- Overrides:
supports
in classAbstractChange
- Parameters:
database
-- Returns:
- always true (in AbstractSQLChange)
-
warn
Description copied from class:AbstractChange
Implementation delegates logic to theSqlGenerator.warn(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)
method on theSqlStatement
objects 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:
warn
in interfaceChange
- Overrides:
warn
in classAbstractChange
-
validate
Description copied from class:AbstractChange
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 theSqlStatement
objects 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:
validate
in interfaceChange
- Overrides:
validate
in 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:
-
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 tonull
to use the default delimiter.- Parameters:
endDelimiter
- the end delimiter to set
-
generateCheckSum
Calculates the checksum based on the contained SQL.- Specified by:
generateCheckSum
in interfaceChange
- Overrides:
generateCheckSum
in 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:
generateStatements
in interfaceChange
-
generateStatementsVolatile
Description copied from class:AbstractChange
Implementation delegates logic to theSqlGenerator.generateStatementsIsVolatile(Database)
method on theSqlStatement
objects returned byChange.generateStatements(liquibase.database.Database)
. If zero or null SqlStatements are returned by generateStatements then this method returns false.- Specified by:
generateStatementsVolatile
in interfaceChange
- Overrides:
generateStatementsVolatile
in classAbstractChange
-
generateRollbackStatementsVolatile
Description copied from class:AbstractChange
Implementation delegates logic to theSqlGenerator.generateRollbackStatementsIsVolatile(Database)
method on theSqlStatement
objects returned byChange.generateStatements(liquibase.database.Database)
If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.- Specified by:
generateRollbackStatementsVolatile
in interfaceChange
- Overrides:
generateRollbackStatementsVolatile
in classAbstractChange
-
checkStatus
Description copied from interface:Change
Validate 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:
checkStatus
in interfaceChange
- Overrides:
checkStatus
in classAbstractChange
-
normalizeLineEndings
-