We are migrating from FreeTDS to Doctrine PDOSQLSrv or SQLSrv (trying both at the monent) and have encountered the problem with the data truncation of the fields that are not updated.
Our update statements look like
update tbl set field1 = isnull(?, field1) , field2 = isnull(?, field2) where id = ?
We have investigated that it is caused by the data type conversion. FreeTDS runs the queries as is, so when you pass the NULL value, NULL is used. However PDOSQLSrv and SQLSrv run queries with sp_prepexec stored procedure, so it is not NULL any more, but
a NULL-valued variable. Unfortunately both libraries convert PHP nulls to char(1) (in documentation https://docs.microsoft.com/en-us/sql/connect/php/default-sql-server-data-types it is said to be varchar(1) but still it doesn't help, I can see char(1) in the
Profiler), so when the field is not updated and we pass NULL, it truncates the data.
So the question is how to pass null correctly?