update query builder support expression

This commit is contained in:
Yuri Kuznetsov
2022-11-11 13:25:50 +02:00
parent 31bf387cbe
commit ef47d3d2bf
3 changed files with 63 additions and 11 deletions
+17 -2
View File
@@ -29,6 +29,7 @@
namespace Espo\ORM\Query;
use Espo\ORM\Query\Part\Expression;
use RuntimeException;
class UpdateBuilder implements Builder
@@ -78,11 +79,25 @@ class UpdateBuilder implements Builder
/**
* Values to set. Column => Value map.
*
* @param array<string,mixed> $set
* @param array<string, scalar|Expression|null> $set
*/
public function set(array $set): self
{
$this->params['set'] = $set;
$modified = [];
foreach ($set as $key => $value) {
if (!$value instanceof Expression) {
$modified[$key] = $value;
continue;
}
$newKey = rtrim($key, ':') . ':';
$modified[$newKey] = $value->getValue();
}
$this->params['set'] = $modified;
return $this;
}