From b6b8c311af589df901243d63ed34756234dc3599 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Jan 2024 09:27:30 +0900 Subject: [PATCH] refactor: use if statement --- system/Database/Postgre/Builder.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/system/Database/Postgre/Builder.php b/system/Database/Postgre/Builder.php index 6da3d377b93b..61562a7f8d65 100644 --- a/system/Database/Postgre/Builder.php +++ b/system/Database/Postgre/Builder.php @@ -566,15 +566,25 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri $sql .= 'WHERE ' . implode( ' AND ', array_map( - static fn ($key, $value) => ( - $value instanceof RawSql ? - $value : - ( - is_string($key) ? - $table . '.' . $key . ' = ' . $that->cast($alias . '.' . $value, $that->getFieldType($table, $key)) : - $table . '.' . $value . ' = ' . $that->cast($alias . '.' . $value, $that->getFieldType($table, $key)) - ) - ), + static function ($key, $value) use ($table, $alias, $that) { + if ($value instanceof RawSql) { + return $value; + } + + if (is_string($key)) { + return $table . '.' . $key . ' = ' + . $that->cast( + $alias . '.' . $value, + $that->getFieldType($table, $key) + ); + } + + return $table . '.' . $value . ' = ' + . $that->cast( + $alias . '.' . $value, + $that->getFieldType($table, $key) + ); + }, array_keys($constraints), $constraints )