1 | |
package liquibase.sqlgenerator.core; |
2 | |
|
3 | |
import liquibase.database.Database; |
4 | |
import liquibase.database.core.H2Database; |
5 | |
import liquibase.database.core.MySQLDatabase; |
6 | |
import liquibase.exception.DatabaseException; |
7 | |
import liquibase.exception.UnexpectedLiquibaseException; |
8 | |
import liquibase.sql.Sql; |
9 | |
import liquibase.sql.UnparsedSql; |
10 | |
import liquibase.sqlgenerator.SqlGeneratorChain; |
11 | |
import liquibase.statement.core.GetViewDefinitionStatement; |
12 | |
|
13 | 10 | public class GetViewDefinitionGeneratorInformationSchemaViews extends GetViewDefinitionGenerator { |
14 | |
@Override |
15 | |
public int getPriority() { |
16 | 1 | return PRIORITY_DATABASE; |
17 | |
} |
18 | |
|
19 | |
@Override |
20 | |
public boolean supports(GetViewDefinitionStatement statement, Database database) { |
21 | 0 | return database instanceof H2Database || database instanceof MySQLDatabase; |
22 | |
} |
23 | |
|
24 | |
@Override |
25 | |
public Sql[] generateSql(GetViewDefinitionStatement statement, Database database, |
26 | |
SqlGeneratorChain sqlGeneratorChain) { |
27 | |
try { |
28 | 0 | return new Sql[] { new UnparsedSql( |
29 | |
"SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '" |
30 | |
+ statement.getViewName() + "' AND TABLE_SCHEMA='" |
31 | |
+ database.convertRequestedSchemaToSchema(statement.getSchemaName()) + "'") }; |
32 | 0 | } catch (DatabaseException e) { |
33 | 0 | throw new UnexpectedLiquibaseException(e); |
34 | |
} |
35 | |
} |
36 | |
} |