Package liquibase.sqlgenerator.core
Class AbstractSqlGenerator<T extends SqlStatement>
- java.lang.Object
-
- liquibase.sqlgenerator.core.AbstractSqlGenerator<T>
-
- Type Parameters:
T
- an implementation of theSqlStatement
specifying which logical SQL statement an instance of this template class is able to generate SQL for.
- All Implemented Interfaces:
PrioritizedService
,SqlGenerator<T>
- Direct Known Subclasses:
AddAutoIncrementGenerator
,AddColumnGenerator
,AddDefaultValueGenerator
,AddForeignKeyConstraintGenerator
,AddPrimaryKeyGenerator
,AddUniqueConstraintGenerator
,AlterSequenceGenerator
,BatchDmlExecutablePreparedStatementGenerator
,ClearDatabaseChangeLogTableGenerator
,CommentGenerator
,CopyRowsGenerator
,CreateDatabaseChangeLogLockTableGenerator
,CreateDatabaseChangeLogTableGenerator
,CreateDatabaseChangeLogTableGeneratorSybase
,CreateIndexGenerator
,CreateProcedureGenerator
,CreateSequenceGenerator
,CreateTableGenerator
,CreateViewGenerator
,CreateViewGeneratorInformix
,DeleteGenerator
,DropColumnGenerator
,DropDefaultValueGenerator
,DropForeignKeyConstraintGenerator
,DropIndexGenerator
,DropPrimaryKeyGenerator
,DropProcedureGenerator
,DropSequenceGenerator
,DropTableGenerator
,DropUniqueConstraintGenerator
,DropViewGenerator
,GetNextChangeSetSequenceValueGenerator
,GetViewDefinitionGenerator
,InitializeDatabaseChangeLogLockTableGenerator
,InsertDataChangeGenerator
,InsertGenerator
,InsertOrUpdateGenerator
,InsertSetGenerator
,LockDatabaseChangeLogGenerator
,MarkChangeSetRanGenerator
,ModifyDataTypeGenerator
,RawParameterizedSqlGenerator
,RawSqlGenerator
,ReindexGeneratorSQLite
,RemoveChangeSetRanStatusGenerator
,RenameColumnGenerator
,RenameSequenceGenerator
,RenameTableGenerator
,RenameViewGenerator
,ReorganizeTableGeneratorDB2
,RuntimeGenerator
,SelectFromDatabaseChangeLogGenerator
,SelectFromDatabaseChangeLogLockGenerator
,SetColumnRemarksGenerator
,SetNullableGenerator
,SetTableRemarksGenerator
,SetViewRemarksGenerator
,StoredProcedureGenerator
,TableIsEmptyGenerator
,TableRowCountGenerator
,TagDatabaseGenerator
,UnlockDatabaseChangeLogGenerator
,UpdateChangeSetChecksumGenerator
,UpdateDataChangeGenerator
,UpdateGenerator
public abstract class AbstractSqlGenerator<T extends SqlStatement> extends Object implements SqlGenerator<T>
Generic template class for an SQL generator able to generate SQL for an object-formSqlStatement
.
-
-
Field Summary
-
Fields inherited from interface liquibase.servicelocator.PrioritizedService
COMPARATOR
-
Fields inherited from interface liquibase.sqlgenerator.SqlGenerator
EMPTY_SQL, PRIORITY_DATABASE, PRIORITY_DEFAULT
-
-
Constructor Summary
Constructors Constructor Description AbstractSqlGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
generateRollbackStatementsIsVolatile(Database database)
boolean
generateStatementsIsVolatile(Database database)
Does this change require access to the database metadata? If true, the change cannot be used in an updateSql-style command.int
getPriority()
Of all the SqlGenerators that "support" a given SqlStatement/Database, SqlGeneratorFactory will return the one with the highest priority.boolean
looksLikeFunctionCall(String value, Database database)
Tries to find out if a given value (part a database-specific SQL statement) is just a simple literal (e.g.boolean
supports(T statement, Database database)
Does this generator support the given statement/database combination? Do not validate the statement with this method, only return if it can support it.Warnings
warn(T statementType, Database database, SqlGeneratorChain<T> sqlGeneratorChain)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface liquibase.sqlgenerator.SqlGenerator
generateSql, validate
-
-
-
-
Method Detail
-
getPriority
public int getPriority()
Description copied from interface:SqlGenerator
Of all the SqlGenerators that "support" a given SqlStatement/Database, SqlGeneratorFactory will return the one with the highest priority.- Specified by:
getPriority
in interfacePrioritizedService
- Specified by:
getPriority
in interfaceSqlGenerator<T extends SqlStatement>
-
generateStatementsIsVolatile
public boolean generateStatementsIsVolatile(Database database)
Description copied from interface:SqlGenerator
Does this change require access to the database metadata? If true, the change cannot be used in an updateSql-style command.- Specified by:
generateStatementsIsVolatile
in interfaceSqlGenerator<T extends SqlStatement>
-
generateRollbackStatementsIsVolatile
public boolean generateRollbackStatementsIsVolatile(Database database)
- Specified by:
generateRollbackStatementsIsVolatile
in interfaceSqlGenerator<T extends SqlStatement>
-
supports
public boolean supports(T statement, Database database)
Description copied from interface:SqlGenerator
Does this generator support the given statement/database combination? Do not validate the statement with this method, only return if it can support it.- Specified by:
supports
in interfaceSqlGenerator<T extends SqlStatement>
-
warn
public Warnings warn(T statementType, Database database, SqlGeneratorChain<T> sqlGeneratorChain)
- Specified by:
warn
in interfaceSqlGenerator<T extends SqlStatement>
-
looksLikeFunctionCall
public boolean looksLikeFunctionCall(String value, Database database)
Tries to find out if a given value (part a database-specific SQL statement) is just a simple literal (e.g. 'Jones', 149.99 or false) or if it is a call to a function within the database (e.g. TO_DATE('28.12.2017', 'dd.mm.yyyy') in Oracle DB). This method is often used to determine if we need to quote literals which are Strings, e.g. if we determine "Dr. Jones" to be a literal, then we generate
but if the value is a function call, we may not quote it, e.g. for "TO_DATE('28.12.2017', 'dd.mm.yyyy')", we need to generate (note the absence of the apostrophes!):INSERT INTO customers(last_name) VALUES('Dr. Jones')
INSERT INTO bookings(booking_date) VALUES (TO_DATE('28.12.2017', 'dd.mm.yyyy'))
- Parameters:
value
- The string to testdatabase
- the database object to test against- Returns:
- true if value looks like a function call, false if it looks like a literal.
-
-