ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

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

Open daneshk opened 5 months ago

daneshk commented 5 months ago

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