Skip to content

Commit 346abf9

Browse files
committed
Fix constraints
Use key value pair for mapping source to destination.
1 parent 0591ba2 commit 346abf9

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
@@ -2702,10 +2702,18 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri
27022702
$sql .= 'ON ' . implode(
27032703
' AND ',
27042704
array_map(
2705-
static fn ($key) => ($key instanceof RawSql ?
2705+
static fn ($key, $value, $id) => (
2706+
$value instanceof RawSql ?
27062707
$key :
2707-
$table . '.' . $key . ' = ' . $alias . '.' . $key),
2708-
$constraints
2708+
(
2709+
is_string($key) ?
2710+
$table . '.' . $id . $key . $id . ' = ' . $alias . '.' . $value :
2711+
$table . '.' . $value . ' = ' . $alias . '.' . $value
2712+
)
2713+
),
2714+
array_keys($constraints),
2715+
$constraints,
2716+
array_fill(0, count($constraints), $this->db->escapeChar)
27092717
)
27102718
);
27112719

system/Database/OCI8/Builder.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,18 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri
465465
$sql .= 'WHERE ' . implode(
466466
' AND ',
467467
array_map(
468-
static fn ($key) => ($key instanceof RawSql ?
468+
static fn ($key, $value, $id) => (
469+
$value instanceof RawSql ?
469470
$key :
470-
$table . '.' . $key . ' = ' . $alias . '.' . $key),
471-
$constraints
471+
(
472+
is_string($key) ?
473+
$table . '.' . $id . $key . $id . ' = ' . $alias . '.' . $value :
474+
$table . '.' . $value . ' = ' . $alias . '.' . $value
475+
)
476+
),
477+
array_keys($constraints),
478+
$constraints,
479+
array_fill(0, count($constraints), $this->db->escapeChar)
472480
)
473481
);
474482

system/Database/Postgre/Builder.php

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

0 commit comments

Comments
 (0)