Skip to content

Commit c4ecd69

Browse files
committed
fix: Postgre updateBatch() SQL type error in WHERE part
1 parent 230af1c commit c4ecd69

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

system/Database/Postgre/Builder.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,20 @@ static function ($key, $value) use ($alias, $fieldTypes) {
372372
$sql .= 'WHERE ' . implode(
373373
' AND ',
374374
array_map(
375-
static fn ($key, $value) => (
376-
($value instanceof RawSql && is_string($key))
377-
?
378-
$table . '.' . $key . ' = ' . $value
379-
:
380-
(
381-
$value instanceof RawSql
382-
?
383-
$value
384-
:
385-
$table . '.' . $value . ' = ' . $alias . '.' . $value
386-
)
387-
),
375+
static function ($key, $value) use ($table, $alias, $fieldTypes) {
376+
if ($value instanceof RawSql && is_string($key)) {
377+
return $table . '.' . $key . ' = ' . $value;
378+
}
379+
380+
if ($value instanceof RawSql) {
381+
return $value;
382+
}
383+
384+
$type = $fieldTypes[trim($value, '"')] ?? null;
385+
$cast = ($type === null) ? '' : '::' . $type;
386+
387+
return $table . '.' . $value . ' = ' . $alias . '.' . $value . $cast;
388+
},
388389
array_keys($constraints),
389390
$constraints
390391
)

0 commit comments

Comments
 (0)