Search in sources :

Example 6 with SqlStatement

use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.

the class EnterpriseDBSqlScriptSmallTest method parsePackages.

@Test
public void parsePackages() throws Exception {
    String source = new ClassPathResource("migration/dbsupport/enterprisedb/sql/package/V1__Package.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
    SqlScript sqlScript = new SqlScript(source, new EnterpriseDBDbSupport(null));
    List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
    assertEquals(2, sqlStatements.size());
    assertEquals(17, sqlStatements.get(0).getLineNumber());
    assertEquals(30, sqlStatements.get(1).getLineNumber());
}
Also used : SqlStatement(org.flywaydb.core.internal.dbsupport.SqlStatement) SqlScript(org.flywaydb.core.internal.dbsupport.SqlScript) ClassPathResource(org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource) Test(org.junit.Test)

Example 7 with SqlStatement

use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.

the class VerticaSqlScriptSmallTest method parseSqlStatementsDo.

@Test
public void parseSqlStatementsDo() throws Exception {
    String source = new ClassPathResource("migration/dbsupport/vertica/sql/dollar/V1__Dollar.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
    SqlScript sqlScript = new SqlScript(source, new VerticaDbSupport(null));
    List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
    assertEquals(10, sqlStatements.size());
    assertEquals(17, sqlStatements.get(0).getLineNumber());
    assertEquals(19, sqlStatements.get(1).getLineNumber());
    assertEquals(20, sqlStatements.get(2).getLineNumber());
}
Also used : SqlStatement(org.flywaydb.core.internal.dbsupport.SqlStatement) SqlScript(org.flywaydb.core.internal.dbsupport.SqlScript) ClassPathResource(org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource) Test(org.junit.Test)

Example 8 with SqlStatement

use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.

the class OracleSqlScriptSmallTest method parseSqlStatementsWithInlineCommentsInsidePlSqlBlocks.

@Test
public void parseSqlStatementsWithInlineCommentsInsidePlSqlBlocks() throws Exception {
    String source = new ClassPathResource("migration/dbsupport/oracle/sql/function/V2__FunctionWithConditionals.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
    SqlScript sqlScript = new SqlScript(source, new OracleDbSupport(null));
    List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
    assertEquals(1, sqlStatements.size());
    assertEquals(18, sqlStatements.get(0).getLineNumber());
    assertTrue(sqlStatements.get(0).getSql().contains("/* for the rich */"));
}
Also used : SqlStatement(org.flywaydb.core.internal.dbsupport.SqlStatement) SqlScript(org.flywaydb.core.internal.dbsupport.SqlScript) ClassPathResource(org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource) Test(org.junit.Test)

Example 9 with SqlStatement

use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.

the class OracleSqlScriptSmallTest method parseSqlStatements.

@Test
public void parseSqlStatements() throws Exception {
    String source = new ClassPathResource("migration/dbsupport/oracle/sql/placeholders/V1__Placeholders.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
    SqlScript sqlScript = new SqlScript(source, new OracleDbSupport(null));
    List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
    assertEquals(3, sqlStatements.size());
    assertEquals(18, sqlStatements.get(0).getLineNumber());
    assertEquals(27, sqlStatements.get(1).getLineNumber());
    assertEquals(32, sqlStatements.get(2).getLineNumber());
    assertEquals("COMMIT", sqlStatements.get(2).getSql());
}
Also used : SqlStatement(org.flywaydb.core.internal.dbsupport.SqlStatement) SqlScript(org.flywaydb.core.internal.dbsupport.SqlScript) ClassPathResource(org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource) Test(org.junit.Test)

Example 10 with SqlStatement

use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.

the class PostgreSQLSqlScriptSmallTest method parseSqlStatementsDo.

@Test
public void parseSqlStatementsDo() throws Exception {
    String source = new ClassPathResource("migration/dbsupport/postgresql/sql/dollar/V2__Even_more_dollars.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
    SqlScript sqlScript = new SqlScript(source, new PostgreSQLDbSupport(null));
    List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
    assertEquals(3, sqlStatements.size());
    assertEquals(17, sqlStatements.get(0).getLineNumber());
    assertEquals(23, sqlStatements.get(1).getLineNumber());
    assertEquals(28, sqlStatements.get(2).getLineNumber());
}
Also used : SqlStatement(org.flywaydb.core.internal.dbsupport.SqlStatement) SqlScript(org.flywaydb.core.internal.dbsupport.SqlScript) ClassPathResource(org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource) Test(org.junit.Test)

Aggregations

SqlStatement (org.flywaydb.core.internal.dbsupport.SqlStatement)21 SqlScript (org.flywaydb.core.internal.dbsupport.SqlScript)19 Test (org.junit.Test)19 ClassPathResource (org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource)11 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 LinkedList (java.util.LinkedList)1 Properties (java.util.Properties)1 FlywayWithDryRun (org.flywaydb.core.FlywayWithDryRun)1 FlywayException (org.flywaydb.core.api.FlywayException)1 MigrationVersion (org.flywaydb.core.api.MigrationVersion)1 Level (org.flywaydb.core.internal.util.logging.console.ConsoleLog.Level)1