Class ParserSqlScript
- java.lang.Object
-
- migratedb.v1.core.internal.sqlscript.ParserSqlScript
-
- All Implemented Interfaces:
Comparable<SqlScript>,SqlScript
public class ParserSqlScript extends Object implements SqlScript
-
-
Field Summary
Fields Modifier and Type Field Description protected Parserparserprotected ResourceresourceThe resource containing the statements.protected List<SqlStatement>sqlStatementsThe sql statements contained in this script.
-
Constructor Summary
Constructors Constructor Description ParserSqlScript(Parser parser, Resource resource, Resource metadataResource, boolean mixed)Creates a new sql script from this source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(SqlScript o)booleanexecuteInTransaction()Whether the execution should take place inside a transaction.ResourcegetResource()intgetSqlStatementCount()SqlStatementIteratorgetSqlStatements()protected voidparse()booleanshouldExecute()Whether the script should execute or not.StringtoString()voidvalidate()Validates this SQL script.
-
-
-
Field Detail
-
sqlStatements
protected final List<SqlStatement> sqlStatements
The sql statements contained in this script.
-
resource
protected final Resource resource
The resource containing the statements.
-
parser
protected final Parser parser
-
-
Constructor Detail
-
ParserSqlScript
public ParserSqlScript(Parser parser, Resource resource, Resource metadataResource, boolean mixed)
Creates a new sql script from this source.- Parameters:
resource- The sql script resource.metadataResource- The sql script metadata resource.mixed- Whether to allow mixing transactional and non-transactional statements within the same migration.
-
-
Method Detail
-
parse
protected void parse()
-
validate
public void validate()
Description copied from interface:SqlScriptValidates this SQL script.
-
getSqlStatements
public SqlStatementIterator getSqlStatements()
- Specified by:
getSqlStatementsin interfaceSqlScript- Returns:
- The sql statements contained in this script.
-
getSqlStatementCount
public int getSqlStatementCount()
- Specified by:
getSqlStatementCountin interfaceSqlScript- Returns:
- The number of sql statements contained in this script.
-
getResource
public final Resource getResource()
- Specified by:
getResourcein interfaceSqlScript- Returns:
- The resource containing the statements.
-
executeInTransaction
public boolean executeInTransaction()
Description copied from interface:SqlScriptWhether the execution should take place inside a transaction. This is useful for databases like PostgreSQL where certain statement can only execute outside a transaction.- Specified by:
executeInTransactionin interfaceSqlScript- Returns:
trueif a transaction should be used (highly recommended), orfalseif not.
-
shouldExecute
public boolean shouldExecute()
Description copied from interface:SqlScriptWhether the script should execute or not.- Specified by:
shouldExecutein interfaceSqlScript- Returns:
trueif the script should execute, orfalseif not.
-
compareTo
public int compareTo(SqlScript o)
- Specified by:
compareToin interfaceComparable<SqlScript>
-
-