| 1 |
|
package liquibase.snapshot.jvm; |
| 2 |
|
|
| 3 |
|
import liquibase.database.Database; |
| 4 |
|
import liquibase.database.core.DB2Database; |
| 5 |
|
import liquibase.exception.DatabaseException; |
| 6 |
|
import liquibase.executor.ExecutorService; |
| 7 |
|
import liquibase.statement.core.RawSqlStatement; |
| 8 |
|
|
| 9 |
|
import java.util.List; |
| 10 |
|
import java.util.Map; |
| 11 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.55 |
|
| 12 |
|
public class DB2DatabaseSnapshotGenerator extends JdbcDatabaseSnapshotGenerator { |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 13 |
0
|
public boolean supports(Database database) {... |
| 14 |
0
|
return database instanceof DB2Database; |
| 15 |
|
} |
| 16 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 17 |
0
|
public int getPriority(Database database) {... |
| 18 |
0
|
return PRIORITY_DATABASE; |
| 19 |
|
} |
| 20 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 21 |
0
|
@Override... |
| 22 |
|
protected String convertTableNameToDatabaseTableName(String tableName) { |
| 23 |
0
|
return tableName.toUpperCase(); |
| 24 |
|
} |
| 25 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 26 |
0
|
@Override... |
| 27 |
|
protected String convertColumnNameToDatabaseTableName(String columnName) { |
| 28 |
0
|
return columnName.toUpperCase(); |
| 29 |
|
} |
| 30 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 31 |
0
|
@Override... |
| 32 |
|
public boolean isColumnAutoIncrement(Database database, String schemaName, String tableName, String columnName) |
| 33 |
|
throws DatabaseException { |
| 34 |
0
|
boolean autoIncrement = false; |
| 35 |
|
|
| 36 |
0
|
List<Map> rs = ExecutorService |
| 37 |
|
.getInstance() |
| 38 |
|
.getExecutor(database) |
| 39 |
|
.queryForList( |
| 40 |
|
new RawSqlStatement("SELECT IDENTITY FROM SYSCAT.COLUMNS WHERE TABSCHEMA = '" |
| 41 |
|
+ database.convertRequestedSchemaToSchema(schemaName) + "' AND TABNAME = '" + tableName |
| 42 |
|
+ "' AND COLNAME = '" + columnName + "' AND HIDDEN != 'S'")); |
| 43 |
|
|
| 44 |
0
|
for (Map row : rs) { |
| 45 |
0
|
String identity = row.get("IDENTITY").toString(); |
| 46 |
0
|
if (identity.equalsIgnoreCase("Y")) { |
| 47 |
0
|
autoIncrement = true; |
| 48 |
|
} |
| 49 |
|
} |
| 50 |
|
|
| 51 |
0
|
return autoIncrement; |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
} |