Skip to content

Commit 9eef0b9

Browse files
authored
Fixed the helper method for inserting nulls to binary fields (#1287)
1 parent 656767a commit 9eef0b9

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

test/functional/sqlsrv/MsHelper.inc

+5-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,11 @@ function insertTestRow($conn, $tbname, $index)
740740
$value = $value[0];
741741
// this might be an input to a decimal, a numeric or a binary field
742742
if (isBinary($col)) {
743-
$value = "0x" . $value; // annotate the input string as a hex string
743+
if (!is_null($value)) {
744+
$value = "0x" . $value; // annotate the input string as a hex string
745+
} else {
746+
$value = null;
747+
}
744748
}
745749
}
746750
if (is_null($value)) {

test/functional/sqlsrv/TC43_FetchData.phpt

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function fetchFields()
2323
AE\createTestTable($conn1, $tableName);
2424

2525
$startRow = 1;
26-
$noRows = 14; // 20;
26+
$noRows = 20;
2727
AE\insertTestRowsByRange($conn1, $tableName, $startRow, $startRow + $noRows - 1);
2828

2929
$query = "SELECT * FROM [$tableName] ORDER BY c27_timestamp";
@@ -50,7 +50,6 @@ function fetchFields()
5050
// should check data even if $fld is null
5151
$data = AE\getInsertData($startRow + $i, $col);
5252
if (!checkData($col, $fld, $data, isBinary($col))) {
53-
// echo("\nData error\nExpected:\n$data\nActual:\n$fld\n");
5453
echo("\nData error\nExpected:\n");
5554
var_dump($data);
5655
echo("\nActual:\n");
@@ -76,7 +75,7 @@ function checkData($col, $actual, $expected, $isBinary)
7675

7776
// First check for nulls
7877
if (is_null($expected)) {
79-
$success = ($isBinary) ? empty($actual) : is_null($actual);
78+
$success = is_null($actual);
8079
if (!$success) {
8180
trace("\nData error\nExpected null but Actual:\n$actual\n");
8281
}

test/functional/sqlsrv/TC51_StreamRead.phpt

+2-4
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ startTest($testName);
129129
if (isLocaleSupported()) {
130130
try {
131131
setUTF8Data(false);
132-
// streamRead(20, 1);
133-
streamRead(14, 1);
132+
streamRead(20, 1);
134133
} catch (Exception $e) {
135134
echo $e->getMessage();
136135
}
@@ -142,8 +141,7 @@ startTest($testName);
142141
try {
143142
setUTF8Data(true);
144143
resetLocaleToDefault();
145-
// streamRead(20, 1);
146-
streamRead(14, 1);
144+
streamRead(20, 1);
147145
} catch (Exception $e) {
148146
echo $e->getMessage();
149147
}

test/functional/sqlsrv/TC55_StreamScrollable.phpt

+2-4
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ startTest($testName);
152152
if (isLocaleSupported()) {
153153
try {
154154
setUTF8Data(false);
155-
// streamScroll(20, 1);
156-
streamScroll(14, 1);
155+
streamScroll(20, 1);
157156
} catch (Exception $e) {
158157
echo $e->getMessage();
159158
}
@@ -165,8 +164,7 @@ startTest($testName);
165164
try {
166165
setUTF8Data(true);
167166
resetLocaleToDefault();
168-
// streamScroll(20, 1);
169-
streamScroll(14, 1);
167+
streamScroll(20, 1);
170168
} catch (Exception $e) {
171169
echo $e->getMessage();
172170
}

0 commit comments

Comments
 (0)