Skip to content

Commit ef13c8e

Browse files
committed
test: fix assertion for SQLSRV
1 parent 5d758fe commit ef13c8e

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

tests/system/Database/Live/UpdateTest.php

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,41 @@ public function testUpdateBatch(): void
152152
];
153153
$this->db->table($table)->updateBatch($data, 'type_varchar');
154154

155-
$this->seeInDatabase($table, [
156-
'type_varchar' => 'test1',
157-
'type_text' => 'updated',
158-
'type_bigint' => 9_999_999,
159-
'type_date' => '2024-01-01',
160-
'type_datetime' => '2024-01-01 09:00:00',
161-
]);
162-
$this->seeInDatabase($table, [
163-
'type_varchar' => 'test2',
164-
'type_text' => 'updated',
165-
'type_bigint' => 9_999_999,
166-
'type_date' => '2024-01-01',
167-
'type_datetime' => '2024-01-01 09:00:00',
168-
]);
155+
if ($this->db->DBDriver === 'SQLSRV') {
156+
// We cannot compare `text` and `varchar` with `=`. It causes the error:
157+
// [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The data types text and varchar are incompatible in the equal to operator.
158+
// And data type `text`, `ntext`, `image` are deprecated in SQL Server 2016
159+
// See https://github.com/codeigniter4/CodeIgniter4/pull/8439#issuecomment-1902535909
160+
$this->seeInDatabase($table, [
161+
'type_varchar' => 'test1',
162+
// 'type_text' => 'updated',
163+
'type_bigint' => 9_999_999,
164+
'type_date' => '2024-01-01',
165+
'type_datetime' => '2024-01-01 09:00:00',
166+
]);
167+
$this->seeInDatabase($table, [
168+
'type_varchar' => 'test2',
169+
// 'type_text' => 'updated',
170+
'type_bigint' => 9_999_999,
171+
'type_date' => '2024-01-01',
172+
'type_datetime' => '2024-01-01 09:00:00',
173+
]);
174+
} else {
175+
$this->seeInDatabase($table, [
176+
'type_varchar' => 'test1',
177+
'type_text' => 'updated',
178+
'type_bigint' => 9_999_999,
179+
'type_date' => '2024-01-01',
180+
'type_datetime' => '2024-01-01 09:00:00',
181+
]);
182+
$this->seeInDatabase($table, [
183+
'type_varchar' => 'test2',
184+
'type_text' => 'updated',
185+
'type_bigint' => 9_999_999,
186+
'type_date' => '2024-01-01',
187+
'type_datetime' => '2024-01-01 09:00:00',
188+
]);
189+
}
169190
}
170191

171192
public function testUpdateWithWhereSameColumn(): void

0 commit comments

Comments
 (0)