Skip to content

Commit 1398cd1

Browse files
committed
Fix constraints
Use key value pair for mapping source to destination.
1 parent 209f304 commit 1398cd1

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

system/Database/BaseBuilder.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,10 +2672,18 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri
26722672
$sql .= 'ON ' . implode(
26732673
' AND ',
26742674
array_map(
2675-
static fn ($key) => ($key instanceof RawSql ?
2675+
static fn ($key, $value, $id) => (
2676+
$value instanceof RawSql ?
26762677
$key :
2677-
$table . '.' . $key . ' = ' . $alias . '.' . $key),
2678-
$constraints
2678+
(
2679+
is_string($key) ?
2680+
$table . '.' . $id . $key . $id . ' = ' . $alias . '.' . $value :
2681+
$table . '.' . $value . ' = ' . $alias . '.' . $value
2682+
)
2683+
),
2684+
array_keys($constraints),
2685+
$constraints,
2686+
array_fill(0, count($constraints), $this->db->escapeChar)
26792687
)
26802688
);
26812689

system/Database/OCI8/Builder.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,18 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri
441441
$sql .= 'WHERE ' . implode(
442442
' AND ',
443443
array_map(
444-
static fn ($key) => ($key instanceof RawSql ?
444+
static fn ($key, $value, $id) => (
445+
$value instanceof RawSql ?
445446
$key :
446-
$table . '.' . $key . ' = ' . $alias . '.' . $key),
447-
$constraints
447+
(
448+
is_string($key) ?
449+
$table . '.' . $id . $key . $id . ' = ' . $alias . '.' . $value :
450+
$table . '.' . $value . ' = ' . $alias . '.' . $value
451+
)
452+
),
453+
array_keys($constraints),
454+
$constraints,
455+
array_fill(0, count($constraints), $this->db->escapeChar)
448456
)
449457
);
450458

system/Database/Postgre/Builder.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,18 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri
431431
$sql .= 'WHERE ' . implode(
432432
' AND ',
433433
array_map(
434-
static fn ($key) => ($key instanceof RawSql ?
434+
static fn ($key, $value, $id) => (
435+
$value instanceof RawSql ?
435436
$key :
436-
$table . '.' . $key . ' = ' . $alias . '.' . $key),
437-
$constraints
437+
(
438+
is_string($key) ?
439+
$table . '.' . $id . $key . $id . ' = ' . $alias . '.' . $value :
440+
$table . '.' . $value . ' = ' . $alias . '.' . $value
441+
)
442+
),
443+
array_keys($constraints),
444+
$constraints,
445+
array_fill(0, count($constraints), $this->db->escapeChar)
438446
)
439447
);
440448

0 commit comments

Comments
 (0)