ballerina-platform/ballerina-library

Passing Null values to the float and date types fails in mssql connector

Opened this issue · 0 comments

Description:
Passing Null values to the float and date types fails in the MSSQL connector, giving the following error.

Operand type clash: varbinary is incompatible with float.

This is because, when passing the NULL to the prepared statements in the underneath code, we need to pass the correct column type like below,

ps.setNull(col_name, java.sql.Types.FLOAT);

But current implementation, we don't know the column type to pass when setting the NULL value to the column. So we use like below,

ps.setNull(col_name, java.sql.Types.NULL)

In MSSQL DB, the varbinary will cast implicitly to nvarchar and int but not float.

Reference: https://stackoverflow.com/questions/15875480/sqlserverexeption-trying-to-insert-null-value-in-a-column

Steps to reproduce:
Make Nullable float column in the MSSQL table and pass NULL value from Ballerina application