Skip to content

Commit

Permalink
Summary 0002644: Large float values fail to load on Sql Server
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Jun 22, 2016
1 parent b0a156e commit 045a246
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
Expand Up @@ -406,7 +406,9 @@ protected Object getObjectValue(String value, Column column, BinaryEncoding enco
objectValue = parseBigInteger(value);
} else if (type == Types.INTEGER || type == Types.SMALLINT || type == Types.BIT || type == Types.TINYINT) {
objectValue = parseInteger(value);
} else if (type == Types.NUMERIC || type == Types.DECIMAL || type == Types.FLOAT
} else if (type == Types.FLOAT) {
objectValue = parseFloat(value);
} else if (type == Types.NUMERIC || type == Types.DECIMAL
|| type == Types.DOUBLE || type == Types.REAL) {
objectValue = parseBigDecimal(value);
} else if (type == Types.BOOLEAN) {
Expand Down Expand Up @@ -443,6 +445,10 @@ protected Object getObjectValue(String value, Column column, BinaryEncoding enco

}

protected Object parseFloat(String value) {
return parseBigDecimal(value);
}

protected Object parseBigDecimal(String value) {
/*
* The number will have either one period or one comma for the decimal
Expand Down
Expand Up @@ -23,6 +23,7 @@
import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.db2.Db2zOsDmlStatement;
import org.jumpmind.db.platform.mssql.MsSqlDmlStatement;
import org.jumpmind.db.platform.mysql.MySqlDmlStatement;
import org.jumpmind.db.platform.oracle.OracleDmlStatement;
import org.jumpmind.db.platform.postgresql.PostgreSqlDmlStatement;
Expand Down Expand Up @@ -89,6 +90,10 @@ public static DmlStatement createDmlStatement(String databaseName, DmlType dmlTy
return new Db2zOsDmlStatement(dmlType, catalogName, schemaName, tableName, keys, columns,
nullKeyValues, ddlBuilder.getDatabaseInfo(),
ddlBuilder.isDelimitedIdentifierModeOn(), textColumnExpression);
} else if (databaseName.startsWith("mssql")) {
return new MsSqlDmlStatement(dmlType, catalogName, schemaName, tableName, keys, columns,
nullKeyValues, ddlBuilder.getDatabaseInfo(),
ddlBuilder.isDelimitedIdentifierModeOn(), textColumnExpression);
} else {
return new DmlStatement(dmlType, catalogName, schemaName, tableName, keys, columns,
nullKeyValues, ddlBuilder.getDatabaseInfo(),
Expand Down
@@ -0,0 +1,33 @@
package org.jumpmind.db.platform.mssql;

import java.sql.Types;

import org.jumpmind.db.model.Column;
import org.jumpmind.db.platform.DatabaseInfo;
import org.jumpmind.db.sql.DmlStatement;

public class MsSqlDmlStatement extends DmlStatement {

public MsSqlDmlStatement(DmlType type, String catalogName, String schemaName, String tableName, Column[] keysColumns, Column[] columns,
boolean[] nullKeyValues, DatabaseInfo databaseInfo, boolean useQuotedIdentifiers, String textColumnExpression) {
super(type, catalogName, schemaName, tableName, keysColumns, columns, nullKeyValues, databaseInfo, useQuotedIdentifiers,
textColumnExpression);
}

public MsSqlDmlStatement(DmlType type, String catalogName, String schemaName, String tableName, Column[] keysColumns, Column[] columns,
boolean[] nullKeyValues, DatabaseInfo databaseInfo, boolean useQuotedIdentifiers, String textColumnExpression,
boolean namedParameters) {
super(type, catalogName, schemaName, tableName, keysColumns, columns, nullKeyValues, databaseInfo, useQuotedIdentifiers,
textColumnExpression, namedParameters);
}

@Override
protected int getTypeCode(Column column, boolean isDateOverrideToTimestamp) {
int type = column.getMappedTypeCode();
if (type == Types.FLOAT) {
return Types.VARCHAR;
} else {
return super.getTypeCode(column, isDateOverrideToTimestamp);
}
}
}
Expand Up @@ -93,7 +93,11 @@ public boolean isClob(int type) {
public boolean canColumnBeUsedInWhereClause(Column column) {
return !column.isOfBinaryType();
}


@Override
protected Object parseFloat(String value) {
return cleanNumber(value);
}
}


Expand Up @@ -156,6 +156,8 @@ protected Integer mapUnknownJdbcTypeForColumn(Map<String, Object> values) {
return Types.LONGVARCHAR;
} else if (typeName != null && typeName.toLowerCase().startsWith("ntext")) {
return Types.CLOB;
} else if (typeName != null && typeName.toLowerCase().equals("float")) {
return Types.FLOAT;
} else if (typeName != null && typeName.toUpperCase().contains(TypeMap.GEOMETRY)) {
return Types.VARCHAR;
} else if (typeName != null && typeName.toUpperCase().contains("VARCHAR") && size > 8000) {
Expand Down

0 comments on commit 045a246

Please sign in to comment.