Skip to content

Commit 5165550

Browse files
committed
refactor: do not use $this->binds when updateBatch()
To reduce memory consumption.
1 parent 8ce7847 commit 5165550

2 files changed

Lines changed: 2 additions & 29 deletions

File tree

system/Database/BaseBuilder.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,9 +2076,8 @@ public function setUpdateBatch($key, string $index = '', ?bool $escape = null)
20762076
$indexSet = true;
20772077
}
20782078

2079-
$bind = $this->setBind($k2, $v2, $escape);
2080-
2081-
$clean[$this->db->protectIdentifiers($k2, false)] = ":{$bind}:";
2079+
$clean[$this->db->protectIdentifiers($k2, false)]
2080+
= $escape ? $this->db->escape($v2) : $v2;
20822081
}
20832082

20842083
if ($indexSet === false) {

tests/system/Database/Builder/UpdateTest.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,6 @@ public function testUpdateBatch()
208208

209209
$space = ' ';
210210

211-
$expected = <<<EOF
212-
UPDATE "jobs" SET "name" = CASE{$space}
213-
WHEN "id" = :id: THEN :name:
214-
WHEN "id" = :id.1: THEN :name.1:
215-
ELSE "name" END, "description" = CASE{$space}
216-
WHEN "id" = :id: THEN :description:
217-
WHEN "id" = :id.1: THEN :description.1:
218-
ELSE "description" END
219-
WHERE "id" IN(:id:,:id.1:)
220-
EOF;
221-
222-
$this->assertSame($expected, $query->getOriginalQuery());
223-
224211
$expected = <<<EOF
225212
UPDATE "jobs" SET "name" = CASE{$space}
226213
WHEN "id" = 2 THEN 'Comedian'
@@ -261,19 +248,6 @@ public function testSetUpdateBatchWithoutEscape()
261248

262249
$space = ' ';
263250

264-
$expected = <<<EOF
265-
UPDATE "jobs" SET "name" = CASE{$space}
266-
WHEN "id" = :id: THEN :name:
267-
WHEN "id" = :id.1: THEN :name.1:
268-
ELSE "name" END, "description" = CASE{$space}
269-
WHEN "id" = :id: THEN :description:
270-
WHEN "id" = :id.1: THEN :description.1:
271-
ELSE "description" END
272-
WHERE "id" IN(:id:,:id.1:)
273-
EOF;
274-
275-
$this->assertSame($expected, $query->getOriginalQuery());
276-
277251
$expected = <<<EOF
278252
UPDATE "jobs" SET "name" = CASE{$space}
279253
WHEN "id" = 2 THEN SUBSTRING(name, 1)

0 commit comments

Comments
 (0)