adjust sql_data_type and column_size for NULL parameters (#1311)
Fix for #1310 - Co-authored-by: George Carrette <gcarrette@wayfair.com>
This commit is contained in:
parent
608a08005c
commit
8de09789af
|
@ -2148,16 +2148,17 @@ void sqlsrv_param::process_null_param(_Inout_ zval* param_z)
|
||||||
// Derive the param SQL type only if it is unknown
|
// Derive the param SQL type only if it is unknown
|
||||||
if (sql_data_type == SQL_UNKNOWN_TYPE) {
|
if (sql_data_type == SQL_UNKNOWN_TYPE) {
|
||||||
// Use the encoding to guess whether the sql_type is binary type or char type. For NULL cases,
|
// Use the encoding to guess whether the sql_type is binary type or char type. For NULL cases,
|
||||||
// if the server type is a binary type, than the server expects the sql_type to be binary type
|
// if the server type is a binary type, then the server expects the sql_type to be binary type
|
||||||
// as well, otherwise an error stating "Implicit conversion not allowed.." is thrown by the
|
// as well, otherwise an error stating "Implicit conversion not allowed.." is thrown by the
|
||||||
// server. For all other server types, setting the sql_type to sql_char works fine.
|
// server. For all other server types, setting the sql_type to sql_varchar works fine.
|
||||||
sql_data_type = (encoding == SQLSRV_ENCODING_BINARY) ? SQL_BINARY : SQL_CHAR;
|
// It must be varchar with column size 0 for ISNULL to work properly.
|
||||||
|
sql_data_type = (encoding == SQLSRV_ENCODING_BINARY) ? SQL_BINARY : SQL_VARCHAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
c_data_type = (encoding == SQLSRV_ENCODING_BINARY) ? SQL_C_BINARY : SQL_C_CHAR;
|
c_data_type = (encoding == SQLSRV_ENCODING_BINARY) ? SQL_C_BINARY : SQL_C_CHAR;
|
||||||
|
|
||||||
if (column_size == SQLSRV_UNKNOWN_SIZE) {
|
if (column_size == SQLSRV_UNKNOWN_SIZE) {
|
||||||
column_size = 1;
|
column_size = (encoding == SQLSRV_ENCODING_BINARY) ? 1 : 0;
|
||||||
decimal_digits = 0;
|
decimal_digits = 0;
|
||||||
}
|
}
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
|
|
Loading…
Reference in a new issue