Skip to content

smallmoney data type is not supported #307

@skvasanth84

Description

@skvasanth84

Bug Report

Versions

  • Driver: 1.0.3 RELEASE
  • Database: MSSQL
  • Java: 21
  • OS: Linux

Current Behavior

When we try to execute the below SQL query we are got the error

Query

SELECT DISTINCT TOP 10 * FROM [Test]

Error

"java.lang.IllegalArgumentException: Cannot decode value of type [java.lang.Object], name [price] server type [smallmoney]"

Stack trace
// your stack trace here

Table schema

CREATE TABLE [e-comm].dbo.test (
id int NULL,
price smallmoney NULL
);

Input Code
-- your SQL here;

Steps to reproduce

Input Code
private Map<String, Object> mapRowToResult(final Row row, final List<String> colNames, final RowMetadata metadata) {
    Map<String, Object> rowMap = new LinkedHashMap();

    for(String colName : colNames) {
        Object value = row.get(colName);
        if (value == null) {
            Class<?> javaType = metadata.getColumnMetadata(colName).getJavaType();
            if (javaType != null && Number.class.isAssignableFrom(javaType)) {
                rowMap.put(colName, 0);
            } else {
                rowMap.put(colName, (Object)null);
            }
        } else if (value instanceof ByteBuf) {
            ByteBuf byteBuf = (ByteBuf)value;
            byte[] copy = new byte[byteBuf.readableBytes()];
            byteBuf.getBytes(byteBuf.readerIndex(), copy);
            rowMap.put(colName, copy);
        } else if (value instanceof Json) {
            Json json = (Json)value;
            rowMap.put(colName, json.asString());
        } else {
            rowMap.put(colName, value);
        }
    }

    return rowMap;
}

Expected behavior/code

Possible Solution

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions