1 | |
package liquibase.sqlgenerator.core; |
2 | |
|
3 | |
import liquibase.database.Database; |
4 | |
import liquibase.database.core.DerbyDatabase; |
5 | |
import liquibase.exception.DatabaseException; |
6 | |
import liquibase.exception.UnexpectedLiquibaseException; |
7 | |
import liquibase.sql.Sql; |
8 | |
import liquibase.sql.UnparsedSql; |
9 | |
import liquibase.sqlgenerator.SqlGeneratorChain; |
10 | |
import liquibase.statement.core.GetViewDefinitionStatement; |
11 | |
|
12 | 10 | public class GetViewDefinitionGeneratorDerby extends GetViewDefinitionGenerator { |
13 | |
@Override |
14 | |
public int getPriority() { |
15 | 1 | return PRIORITY_DATABASE; |
16 | |
} |
17 | |
|
18 | |
@Override |
19 | |
public boolean supports(GetViewDefinitionStatement statement, Database database) { |
20 | 0 | return database instanceof DerbyDatabase; |
21 | |
} |
22 | |
|
23 | |
@Override |
24 | |
public Sql[] generateSql(GetViewDefinitionStatement statement, Database database, |
25 | |
SqlGeneratorChain sqlGeneratorChain) { |
26 | |
try { |
27 | 0 | return new Sql[] { new UnparsedSql( |
28 | |
"select V.VIEWDEFINITION from SYS.SYSVIEWS V, SYS.SYSTABLES T, SYS.SYSSCHEMAS S WHERE V.TABLEID=T.TABLEID AND T.SCHEMAID=S.SCHEMAID AND T.TABLETYPE='V' AND T.TABLENAME='" |
29 | |
+ statement.getViewName() |
30 | |
+ "' AND S.SCHEMANAME='" |
31 | |
+ database.convertRequestedSchemaToSchema(statement.getSchemaName()) + "'") }; |
32 | 0 | } catch (DatabaseException e) { |
33 | 0 | throw new UnexpectedLiquibaseException(e); |
34 | |
} |
35 | |
} |
36 | |
} |