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.exception.ValidationErrors; |
8 | |
import liquibase.sql.Sql; |
9 | |
import liquibase.sql.UnparsedSql; |
10 | |
import liquibase.sqlgenerator.SqlGeneratorChain; |
11 | |
import liquibase.statement.core.SelectSequencesStatement; |
12 | |
|
13 | 10 | public class SelectSequencesGeneratorDerby extends AbstractSqlGenerator<SelectSequencesStatement> { |
14 | |
@Override |
15 | |
public int getPriority() { |
16 | 1 | return PRIORITY_DATABASE; |
17 | |
} |
18 | |
|
19 | |
@Override |
20 | |
public boolean supports(SelectSequencesStatement statement, Database database) { |
21 | 0 | return database instanceof DerbyDatabase; |
22 | |
} |
23 | |
|
24 | |
public ValidationErrors validate(SelectSequencesStatement statement, Database database, |
25 | |
SqlGeneratorChain sqlGeneratorChain) { |
26 | 0 | return new ValidationErrors(); |
27 | |
} |
28 | |
|
29 | |
public Sql[] generateSql(SelectSequencesStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { |
30 | |
try { |
31 | 0 | String schemaName = database.convertRequestedSchemaToSchema(statement.getSchemaName()); |
32 | 0 | return new Sql[] { new UnparsedSql("SELECT " + " seq.SEQUENCENAME AS SEQUENCE_NAME " + "FROM " |
33 | |
+ " SYS.SYSSEQUENCES seq, " + " SYS.SYSSCHEMAS sch " + "WHERE " + " sch.SCHEMANAME = '" |
34 | |
+ schemaName + "' AND " + " sch.SCHEMAID = seq.SCHEMAID") }; |
35 | 0 | } catch (DatabaseException e) { |
36 | 0 | throw new UnexpectedLiquibaseException(e); |
37 | |
} |
38 | |
} |
39 | |
} |