From 3aa051e1a14dfc40a77757247b6849dbd2c9c69d Mon Sep 17 00:00:00 2001 From: Saumar Hajjar Date: Mon, 21 Sep 2015 23:36:42 -0300 Subject: [PATCH] FS-7673: ODBC NULL value incorrectly evaluated in mod_v8 --- src/mod/languages/mod_v8/src/fsodbc.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mod/languages/mod_v8/src/fsodbc.cpp b/src/mod/languages/mod_v8/src/fsodbc.cpp index 79cf57a906..80bc90ebd7 100644 --- a/src/mod/languages/mod_v8/src/fsodbc.cpp +++ b/src/mod/languages/mod_v8/src/fsodbc.cpp @@ -315,12 +315,17 @@ JS_ODBC_FUNCTION_IMPL(GetData) SQLULEN ColumnSize; SQLCHAR name[1024] = ""; SQLCHAR *data = _colbuf; - + SQLLEN pcbValue; + SQLDescribeCol(_stmt, x, name, sizeof(name), &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable); - SQLGetData(_stmt, x, SQL_C_CHAR, _colbuf, _cblen, NULL); + SQLGetData(_stmt, x, SQL_C_CHAR, _colbuf, _cblen, &pcbValue); if (name) { - arg->Set(String::NewFromUtf8(GetIsolate(), (const char *)name), String::NewFromUtf8(GetIsolate(), data ? (const char *)data : "")); + if (SQL_NULL_DATA == pcbValue) { + arg->Set(String::NewFromUtf8(GetIsolate(), (const char *)name), Null(info.GetIsolate())); + } else { + arg->Set(String::NewFromUtf8(GetIsolate(), (const char *)name), String::NewFromUtf8(GetIsolate(), data ? (const char *)data : "")); + } } }