Permalink
Browse files

working on DB2 failing integration tests. Still not working

  • Loading branch information...
1 parent d3c590b commit ce633955176850f928d35067b7f91a3f1b3c4f57 @nvoxland nvoxland committed Aug 20, 2012
@@ -697,6 +697,12 @@ public boolean isCaseSensitive() {
}
public boolean objectNamesEqual(String name1, String name2) {
+ if (name1 == null && name2 == null) {
+ return true;
+ }
+ if (name1 == null || name2 == null) {
+ return false;
+ }
if (isCaseSensitive()) {
return name1.equals(name2);
} else {
@@ -37,6 +37,11 @@ public Integer getDefaultPort() {
return 446;
}
+ @Override
+ public boolean supportsSchemas() {
+ return false;
+ }
+
@Override
protected String getDefaultDatabaseProductName() {
return "DB2";
@@ -73,11 +78,6 @@ public String getDefaultSchemaName() {
return defaultSchemaName;
}
- @Override
- public Schema correctSchema(Schema schema) {
- return schema;
- }
-
@Override
protected String correctObjectName(String objectName) {
return objectName.toUpperCase();
@@ -19,12 +19,12 @@ public DatabaseDataType toDatabaseDataType(Database database) {
} else if (database instanceof MSSQLDatabase) {
return new DatabaseDataType("BIT");
} else if (database instanceof MySQLDatabase) {
- return new DatabaseDataType("TINYINT",1);
+ return new DatabaseDataType("TINYINT", 1);
} else if (database instanceof OracleDatabase) {
return new DatabaseDataType("NUMBER", 1);
- } else if (database instanceof SybaseASADatabase || database instanceof SybaseDatabase) {
+ } else if (database instanceof SybaseASADatabase || database instanceof SybaseDatabase) {
return new DatabaseDataType("BIT");
- } else if (database instanceof DerbyDatabase) {
+ } else if (database instanceof DerbyDatabase) {
return new DatabaseDataType("SMALLINT");
}
@@ -61,25 +61,46 @@ public String objectToString(Object value, Database database) {
return returnValue;
}
- //todo: informix 't' and 'f'
+ protected boolean isNumericBoolean(Database database) {
+ if (database instanceof CacheDatabase
+ || database instanceof DB2Database
+ || database instanceof FirebirdDatabase
+ || database instanceof MSSQLDatabase
+ || database instanceof MySQLDatabase
+ || database instanceof OracleDatabase
+ || database instanceof SybaseASADatabase
+ || database instanceof SybaseDatabase
+ || database instanceof DerbyDatabase) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
/**
* The database-specific value to use for "false" "boolean" columns.
*/
public String getFalseBooleanValue(Database database) {
- if (database instanceof MSSQLDatabase) {
+ if (isNumericBoolean(database)) {
return "0";
}
+ if (database instanceof InformixDatabase) {
+ return "f";
+ }
return "FALSE";
}
/**
* The database-specific value to use for "true" "boolean" columns.
*/
public String getTrueBooleanValue(Database database) {
- if (database instanceof MSSQLDatabase) {
+ if (isNumericBoolean(database)) {
return "1";
}
+ if (database instanceof InformixDatabase) {
+ return "t";
+ }
return "TRUE";
}
@@ -1,6 +1,7 @@
package liquibase.datatype.core;
import liquibase.database.Database;
+import liquibase.database.core.DB2Database;
import liquibase.database.core.MySQLDatabase;
import liquibase.datatype.DataTypeInfo;
import liquibase.datatype.DatabaseDataType;
@@ -10,7 +11,7 @@
public class NumericType extends LiquibaseDataType {
@Override
public DatabaseDataType toDatabaseDataType(Database database) {
- if (database instanceof MySQLDatabase) {
+ if (database instanceof MySQLDatabase || database instanceof DB2Database) {
return new DatabaseDataType("numeric", getParameters());
}
return super.toDatabaseDataType(database);
@@ -55,6 +55,7 @@ public boolean hasTable(Schema schema, String tableName, Database database) {
try {
if (database != null) {
tableName = database.correctTableName(tableName);
+ schema = database.correctSchema(schema);
}
ResultSet rs = getMetaData(database).getTables(schema.getCatalogName(), schema.getName(), tableName, new String[]{"TABLE"});
try {
@@ -347,6 +348,7 @@ protected DatabaseMetaData getMetaData(Database database) throws SQLException {
protected void readTables(DatabaseSnapshot snapshot, Schema schema, DatabaseMetaData databaseMetaData) throws SQLException, DatabaseException {
+ schema = snapshot.getDatabase().correctSchema(schema);
Database database = snapshot.getDatabase();
updateListeners("Reading tables for " + database.toString() + " ...");

0 comments on commit ce63395

Please sign in to comment.