Skip to content

Commit 413d0c2

Browse files
committed
Fix SQLite and OCI8
A couple of small fixes. OCI8 is strict about identifiers. SQLite alternate update needed a small adjustment.
1 parent cddd67c commit 413d0c2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

system/Database/SQLite3/Builder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
9393
$final = [];
9494

9595
foreach ($values as $val) {
96+
$val = array_combine($keys, $val);
97+
9698
$ids[] = $val[$index];
9799

98100
foreach (array_keys($val) as $field) {

tests/system/Database/Live/UpdateTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ public function testSetWithBoolean()
242242

243243
public function testUpdateBatchTwoConstraints()
244244
{
245+
if (version_compare($this->db->getVersion(), '3.33.0') < 0) {
246+
$this->markTestSkipped('This SQLite version does not support this test.');
247+
}
248+
245249
$data = [
246250
[
247251
'id' => 1,
@@ -269,6 +273,10 @@ public function testUpdateBatchTwoConstraints()
269273

270274
public function testUpdateBatchConstraintsRawSqlandAlias()
271275
{
276+
if (version_compare($this->db->getVersion(), '3.33.0') < 0) {
277+
$this->markTestSkipped('This SQLite version does not support this test.');
278+
}
279+
272280
$data = [
273281
[
274282
'id' => 1,
@@ -292,7 +300,12 @@ public function testUpdateBatchConstraintsRawSqlandAlias()
292300
],
293301
];
294302

295-
$this->db->table('user')->setData($data, true, 'd')->updateBatch(null, ['id', new RawSql("d.country LIKE 'U%'")]);
303+
$this->db->table('user')->setData($data, true, 'd')->updateBatch(
304+
null,
305+
['id', new RawSql($this->db->protectIdentifiers('d')
306+
. '.' . $this->db->protectIdentifiers('country')
307+
. " LIKE 'U%'")]
308+
);
296309

297310
$this->seeInDatabase('user', [
298311
'name' => 'Derek Jones Changes',

0 commit comments

Comments
 (0)