Skip to content

Commit

Permalink
Cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
freost committed Jan 20, 2025
1 parent 115767a commit 8725b0f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/mako/database/query/compilers/Firebird.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function updateAndReturn(array $values, array $return): array
{
$query = $this->update($values);

$query['sql'] .= ' RETURNING ' . $this->columns($return);
$query['sql'] .= ' RETURNING ' . $this->columnNames($return);

return $query;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mako/database/query/compilers/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function updateAndReturn(array $values, array $return): array
{
$query = $this->update($values);

$query['sql'] .= ' RETURNING ' . $this->columns($return);
$query['sql'] .= ' RETURNING ' . $this->columnNames($return);

return $query;
}
Expand Down
8 changes: 5 additions & 3 deletions src/mako/database/query/compilers/SQLServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
use mako\database\query\Raw;
use mako\database\query\Subquery;

use function array_map;
use function explode;
use function implode;
use function str_replace;

Expand Down Expand Up @@ -123,12 +121,16 @@ protected function offset(?int $offset): string
*/
public function updateAndReturn(array $values, array $return): array
{
foreach ($return as $key => $column) {
$return[$key] = "inserted.{$this->columnName($column)}";
}

$sql = $this->query->getPrefix()
. 'UPDATE '
. $this->escapeTableName($this->query->getTable())
. ' SET '
. $this->updateColumns($values)
. ' OUTPUT ' . implode(', ', array_map(fn ($column) => "inserted.{$column}", explode(', ', $this->columns($return))))
. ' OUTPUT ' . implode(', ', $return)
. $this->wheres($this->query->getWheres());

return ['sql' => $sql, 'params' => $this->params];
Expand Down
2 changes: 1 addition & 1 deletion src/mako/database/query/compilers/SQLite.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function updateAndReturn(array $values, array $return): array
{
$query = $this->update($values);

$query['sql'] .= ' RETURNING ' . $this->columns($return);
$query['sql'] .= ' RETURNING ' . $this->columnNames($return);

return $query;
}
Expand Down

0 comments on commit 8725b0f

Please sign in to comment.