Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql_variant issue with String type #442

Merged
merged 5 commits into from
Aug 29, 2017
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
Original file line number Diff line number Diff line change
Expand Up @@ -3104,7 +3104,7 @@ public void apply(TypeInfo typeInfo,
*/
public void apply(TypeInfo typeInfo,
TDSReader tdsReader) throws SQLServerException {
typeInfo.ssLenType = SSLenType.LONGLENTYPE; //Variant type should be LONGLENTYPE length.
typeInfo.ssLenType = SSLenType.LONGLENTYPE; //sql_variant type should be LONGLENTYPE length.
typeInfo.maxLength = tdsReader.readInt();
typeInfo.ssType = SSType.SQL_VARIANT;
}
Expand Down Expand Up @@ -4115,7 +4115,6 @@ else if (TDSType.NUMERICN == baseType)

case MONEY4:
jdbcType = JDBCType.SMALLMONEY;
typeInfo.setMaxLength(4);
precision = Long.toString(Long.MAX_VALUE).length();
typeInfo.setPrecision(precision);
scale = 4;
Expand All @@ -4128,7 +4127,6 @@ else if (TDSType.NUMERICN == baseType)

case MONEY8:
jdbcType = JDBCType.MONEY;
typeInfo.setMaxLength(8);
precision = Long.toString(Long.MAX_VALUE).length();
scale = 4;
typeInfo.setPrecision(precision);
Expand Down Expand Up @@ -4179,9 +4177,7 @@ else if (TDSType.BIGCHAR == baseType)
jdbcType = JDBCType.CHAR;
collation = tdsReader.readCollation();
typeInfo.setSQLCollation(collation);
typeInfo.setSSLenType(SSLenType.USHORTLENTYPE);
maxLength = tdsReader.readUnsignedShort();
typeInfo.setMaxLength(maxLength);
if (maxLength > DataTypes.SHORT_VARTYPE_MAX_BYTES)
tdsReader.throwInvalidTDS();
typeInfo.setDisplaySize(maxLength);
Expand All @@ -4205,7 +4201,6 @@ else if (TDSType.NVARCHAR == baseType)
jdbcType = JDBCType.NVARCHAR;
collation = tdsReader.readCollation();
typeInfo.setSQLCollation(collation);
typeInfo.setSSLenType(SSLenType.USHORTLENTYPE);
maxLength = tdsReader.readUnsignedShort();
if (maxLength > DataTypes.SHORT_VARTYPE_MAX_BYTES || 0 != maxLength % 2)
tdsReader.throwInvalidTDS();
Expand Down Expand Up @@ -4272,7 +4267,6 @@ else if (TDSType.BIGVARBINARY == baseType)
jdbcType = JDBCType.VARBINARY;
maxLength = tdsReader.readUnsignedShort();
internalVariant.setMaxLength(maxLength);
typeInfo.setMaxLength(maxLength);
if (maxLength > DataTypes.SHORT_VARTYPE_MAX_BYTES)
tdsReader.throwInvalidTDS();
typeInfo.setDisplaySize(2 * maxLength);
Expand Down