Skip to content

Commit

Permalink
0001969: Integer conversion between Oracle and PostgreSQL maps to wro…
Browse files Browse the repository at this point in the history
…ng type
  • Loading branch information
chenson42 committed Sep 25, 2014
1 parent 6cf5bbd commit 4bc236f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Expand Up @@ -19,6 +19,7 @@
* under the License.
*/

import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -314,7 +315,13 @@ public List<IModelChange> compareTables(Database sourceModel, Table sourceTable,
public List<TableChange> compareColumns(Table sourceTable, Column sourceColumn,
Table targetTable, Column targetColumn) {
ArrayList<TableChange> changes = new ArrayList<TableChange>();
if (targetColumn.getMappedTypeCode() != sourceColumn.getMappedTypeCode()

int sourceTypeCode = sourceColumn.getMappedTypeCode();
int targetTypeCode = targetColumn.getMappedTypeCode();
boolean compatible =
(sourceTypeCode == Types.NUMERIC || sourceTypeCode == Types.DECIMAL) &&
(targetTypeCode == Types.INTEGER || targetTypeCode == Types.BIGINT);
if (!compatible && targetColumn.getMappedTypeCode() != sourceColumn.getMappedTypeCode()
&& platformInfo.getTargetJdbcType(targetColumn.getMappedTypeCode()) != sourceColumn
.getMappedTypeCode()) {
log.debug(
Expand Down
Expand Up @@ -149,20 +149,7 @@ protected Column readColumn(DatabaseMetaDataWrapper metaData, Map<String, Object
// We're back-mapping the NUMBER columns returned by Oracle
// Note that the JDBC driver returns DECIMAL for these NUMBER
// columns
if (column.getScale() == 0) {
if (column.getSizeAsInt() == 22) {
// TODO: This is causing several Oracle unit tests to fail.
// if (isColumnInteger((String) values.get("TABLE_NAME"),
// (String) values.get("COLUMN_NAME"))) {
// column.setMappedTypeCode(Types.INTEGER);
// } else {
// column.setMappedTypeCode(Types.REAL);
// }
column.setMappedTypeCode(Types.INTEGER);
} else if (column.getSizeAsInt() == 38){
column.setMappedTypeCode(Types.BIGINT);
}
} else if (column.getScale() <= -127 || column.getScale() >= 127) {
if (column.getScale() <= -127 || column.getScale() >= 127) {
if (column.getSizeAsInt() == 0) {
/*
* Latest oracle jdbc drivers for 11g return (0,-127) for
Expand All @@ -173,7 +160,7 @@ protected Column readColumn(DatabaseMetaDataWrapper metaData, Map<String, Object
*/
if (isColumnInteger((String)values.get("TABLE_NAME"),
(String)values.get("COLUMN_NAME"))) {
column.setMappedTypeCode(Types.INTEGER);
column.setMappedTypeCode(Types.BIGINT);
}
} else if (column.getSizeAsInt() <= 63) {
column.setMappedTypeCode(Types.REAL);
Expand Down

0 comments on commit 4bc236f

Please sign in to comment.