From 9eef0b946c1c69c8d58afe77d348715a7d561e3a Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 12 Aug 2021 08:05:48 -0700 Subject: [PATCH] Fixed the helper method for inserting nulls to binary fields (#1287) --- test/functional/sqlsrv/MsHelper.inc | 6 +++++- test/functional/sqlsrv/TC43_FetchData.phpt | 5 ++--- test/functional/sqlsrv/TC51_StreamRead.phpt | 6 ++---- test/functional/sqlsrv/TC55_StreamScrollable.phpt | 6 ++---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/test/functional/sqlsrv/MsHelper.inc b/test/functional/sqlsrv/MsHelper.inc index c9d18688..cdff8764 100644 --- a/test/functional/sqlsrv/MsHelper.inc +++ b/test/functional/sqlsrv/MsHelper.inc @@ -740,7 +740,11 @@ function insertTestRow($conn, $tbname, $index) $value = $value[0]; // this might be an input to a decimal, a numeric or a binary field if (isBinary($col)) { - $value = "0x" . $value; // annotate the input string as a hex string + if (!is_null($value)) { + $value = "0x" . $value; // annotate the input string as a hex string + } else { + $value = null; + } } } if (is_null($value)) { diff --git a/test/functional/sqlsrv/TC43_FetchData.phpt b/test/functional/sqlsrv/TC43_FetchData.phpt index 0e6c6a0d..23bf92b8 100644 --- a/test/functional/sqlsrv/TC43_FetchData.phpt +++ b/test/functional/sqlsrv/TC43_FetchData.phpt @@ -23,7 +23,7 @@ function fetchFields() AE\createTestTable($conn1, $tableName); $startRow = 1; - $noRows = 14; // 20; + $noRows = 20; AE\insertTestRowsByRange($conn1, $tableName, $startRow, $startRow + $noRows - 1); $query = "SELECT * FROM [$tableName] ORDER BY c27_timestamp"; @@ -50,7 +50,6 @@ function fetchFields() // should check data even if $fld is null $data = AE\getInsertData($startRow + $i, $col); if (!checkData($col, $fld, $data, isBinary($col))) { - // echo("\nData error\nExpected:\n$data\nActual:\n$fld\n"); echo("\nData error\nExpected:\n"); var_dump($data); echo("\nActual:\n"); @@ -76,7 +75,7 @@ function checkData($col, $actual, $expected, $isBinary) // First check for nulls if (is_null($expected)) { - $success = ($isBinary) ? empty($actual) : is_null($actual); + $success = is_null($actual); if (!$success) { trace("\nData error\nExpected null but Actual:\n$actual\n"); } diff --git a/test/functional/sqlsrv/TC51_StreamRead.phpt b/test/functional/sqlsrv/TC51_StreamRead.phpt index 4a61216d..565e41fe 100644 --- a/test/functional/sqlsrv/TC51_StreamRead.phpt +++ b/test/functional/sqlsrv/TC51_StreamRead.phpt @@ -129,8 +129,7 @@ startTest($testName); if (isLocaleSupported()) { try { setUTF8Data(false); - // streamRead(20, 1); - streamRead(14, 1); + streamRead(20, 1); } catch (Exception $e) { echo $e->getMessage(); } @@ -142,8 +141,7 @@ startTest($testName); try { setUTF8Data(true); resetLocaleToDefault(); - // streamRead(20, 1); - streamRead(14, 1); + streamRead(20, 1); } catch (Exception $e) { echo $e->getMessage(); } diff --git a/test/functional/sqlsrv/TC55_StreamScrollable.phpt b/test/functional/sqlsrv/TC55_StreamScrollable.phpt index ad14bd69..4fde1464 100644 --- a/test/functional/sqlsrv/TC55_StreamScrollable.phpt +++ b/test/functional/sqlsrv/TC55_StreamScrollable.phpt @@ -152,8 +152,7 @@ startTest($testName); if (isLocaleSupported()) { try { setUTF8Data(false); - // streamScroll(20, 1); - streamScroll(14, 1); + streamScroll(20, 1); } catch (Exception $e) { echo $e->getMessage(); } @@ -165,8 +164,7 @@ startTest($testName); try { setUTF8Data(true); resetLocaleToDefault(); - // streamScroll(20, 1); - streamScroll(14, 1); + streamScroll(20, 1); } catch (Exception $e) { echo $e->getMessage(); }