Search in sources :

Example 1 with GetViewDefinitionStatement

use of liquibase.statement.core.GetViewDefinitionStatement in project liquibase by liquibase.

the class DB2Database method getViewDefinition.

@Override
public String getViewDefinition(CatalogAndSchema schema, String viewName) throws DatabaseException {
    schema = schema.customize(this);
    String definition = ExecutorService.getInstance().getExecutor(this).queryForObject(new GetViewDefinitionStatement(schema.getCatalogName(), schema.getSchemaName(), viewName), String.class);
    return "FULL_DEFINITION: " + definition;
}
Also used : GetViewDefinitionStatement(liquibase.statement.core.GetViewDefinitionStatement)

Example 2 with GetViewDefinitionStatement

use of liquibase.statement.core.GetViewDefinitionStatement in project liquibase by liquibase.

the class InformixDatabase method getViewDefinition.

@Override
public String getViewDefinition(CatalogAndSchema schema, final String viewName) throws DatabaseException {
    schema = schema.customize(this);
    List<Map<String, ?>> retList = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", this).queryForList(new GetViewDefinitionStatement(schema.getCatalogName(), schema.getSchemaName(), viewName));
    // building the view definition from the multiple rows
    StringBuilder sb = new StringBuilder();
    for (Map rowMap : retList) {
        String s = (String) rowMap.get("VIEWTEXT");
        sb.append(s);
    }
    return CREATE_VIEW_AS_PATTERN.matcher(sb.toString()).replaceFirst("");
}
Also used : Map(java.util.Map) GetViewDefinitionStatement(liquibase.statement.core.GetViewDefinitionStatement)

Example 3 with GetViewDefinitionStatement

use of liquibase.statement.core.GetViewDefinitionStatement in project liquibase by liquibase.

the class SybaseDatabase method getViewDefinition.

@Override
public String getViewDefinition(CatalogAndSchema schema, String viewName) throws DatabaseException {
    schema = schema.customize(this);
    GetViewDefinitionStatement statement = new GetViewDefinitionStatement(schema.getCatalogName(), schema.getSchemaName(), viewName);
    Executor executor = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", this);
    @SuppressWarnings("unchecked") List<String> definitionRows = (List<String>) executor.queryForList(statement, String.class);
    StringBuilder definition = new StringBuilder();
    for (String d : definitionRows) {
        definition.append(d);
    }
    return definition.toString();
}
Also used : Executor(liquibase.executor.Executor) ExecutorService(liquibase.executor.ExecutorService) List(java.util.List) GetViewDefinitionStatement(liquibase.statement.core.GetViewDefinitionStatement)

Example 4 with GetViewDefinitionStatement

use of liquibase.statement.core.GetViewDefinitionStatement in project liquibase by liquibase.

the class GetViewDefinitionGeneratorSybaseTest method testGenerateSqlForDefaultSchema.

@Test
public void testGenerateSqlForDefaultSchema() {
    GetViewDefinitionGeneratorSybase generator = new GetViewDefinitionGeneratorSybase();
    GetViewDefinitionStatement statement = new GetViewDefinitionStatement(null, null, "view_name");
    Sql[] sql = generator.generateSql(statement, new SybaseDatabase(), null);
    assertEquals(1, sql.length);
    assertEquals("select text from syscomments where id = object_id('dbo.view_name') order by colid", sql[0].toSql());
}
Also used : SybaseDatabase(liquibase.database.core.SybaseDatabase) GetViewDefinitionStatement(liquibase.statement.core.GetViewDefinitionStatement) Sql(liquibase.sql.Sql) Test(org.junit.Test)

Example 5 with GetViewDefinitionStatement

use of liquibase.statement.core.GetViewDefinitionStatement in project liquibase by liquibase.

the class GetViewDefinitionGeneratorSybaseTest method testGenerateSqlForNamedSchema.

@Test
public void testGenerateSqlForNamedSchema() {
    GetViewDefinitionGeneratorSybase generator = new GetViewDefinitionGeneratorSybase();
    GetViewDefinitionStatement statement = new GetViewDefinitionStatement(null, "owner", "view_name");
    Sql[] sql = generator.generateSql(statement, new SybaseDatabase(), null);
    assertEquals(1, sql.length);
    assertEquals("select text from syscomments where id = object_id('OWNER.view_name') order by colid", sql[0].toSql());
}
Also used : SybaseDatabase(liquibase.database.core.SybaseDatabase) GetViewDefinitionStatement(liquibase.statement.core.GetViewDefinitionStatement) Sql(liquibase.sql.Sql) Test(org.junit.Test)

Aggregations

GetViewDefinitionStatement (liquibase.statement.core.GetViewDefinitionStatement)8 SybaseDatabase (liquibase.database.core.SybaseDatabase)2 Sql (liquibase.sql.Sql)2 Test (org.junit.Test)2 SQLException (java.sql.SQLException)1 List (java.util.List)1 Map (java.util.Map)1 CatalogAndSchema (liquibase.CatalogAndSchema)1 AbstractJdbcDatabase (liquibase.database.AbstractJdbcDatabase)1 Database (liquibase.database.Database)1 InformixDatabase (liquibase.database.core.InformixDatabase)1 MariaDBDatabase (liquibase.database.core.MariaDBDatabase)1 MySQLDatabase (liquibase.database.core.MySQLDatabase)1 OracleDatabase (liquibase.database.core.OracleDatabase)1 DatabaseException (liquibase.exception.DatabaseException)1 Executor (liquibase.executor.Executor)1 ExecutorService (liquibase.executor.ExecutorService)1 CachedRow (liquibase.snapshot.CachedRow)1 JdbcDatabaseSnapshot (liquibase.snapshot.JdbcDatabaseSnapshot)1 Schema (liquibase.structure.core.Schema)1