Skip to content

Commit

Permalink
fix: Postgre updateBatch() SQL type error in WHERE part
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jan 22, 2024
1 parent 230af1c commit c4ecd69
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions system/Database/Postgre/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,19 +372,20 @@ static function ($key, $value) use ($alias, $fieldTypes) {
$sql .= 'WHERE ' . implode(
' AND ',
array_map(
static fn ($key, $value) => (
($value instanceof RawSql && is_string($key))
?
$table . '.' . $key . ' = ' . $value
:
(
$value instanceof RawSql
?
$value
:
$table . '.' . $value . ' = ' . $alias . '.' . $value
)
),
static function ($key, $value) use ($table, $alias, $fieldTypes) {
if ($value instanceof RawSql && is_string($key)) {
return $table . '.' . $key . ' = ' . $value;
}

if ($value instanceof RawSql) {
return $value;
}

$type = $fieldTypes[trim($value, '"')] ?? null;
$cast = ($type === null) ? '' : '::' . $type;

return $table . '.' . $value . ' = ' . $alias . '.' . $value . $cast;
},
array_keys($constraints),
$constraints
)
Expand Down

0 comments on commit c4ecd69

Please sign in to comment.