diff --git a/src/Query/Grammars/Grammar.php b/src/Query/Grammars/Grammar.php index 3d5d0b0..0f5c01d 100755 --- a/src/Query/Grammars/Grammar.php +++ b/src/Query/Grammars/Grammar.php @@ -181,19 +181,15 @@ public function compileInsertOrIgnoreUsing(Builder $query, array $columns, strin /** * Compile an update statement into SQL. - * - * @param array $values */ - public function compileUpdate(Builder $query, $values): string + public function compileUpdate(Builder $query, array $values): string { $table = $this->wrapTable($query->from); // Each one of the columns in the update statements needs to be wrapped in the // keyword identifiers, also a place-holder needs to be created for each of // the values in the list of bindings so we can make the sets statements. - $columns = collect($values)->map(function ($value, $key) { - return $this->wrap($key) . ' = ' . $this->parameter($value); - })->implode(', '); + $columns = $this->compileUpdateColumns($query, $values); // If the query has any "join" clauses, we will setup the joins on the builder // and compile them so we can attach them to this update, as update queries @@ -371,6 +367,16 @@ public function compileJoinLateral(JoinLateralClause $join, string $expression): throw new RuntimeException('This database engine does not support lateral joins.'); } + /** + * Compile the columns for an update statement. + */ + protected function compileUpdateColumns(Builder $query, array $values): string + { + return collect($values)->map(function ($value, $key) { + return $this->wrap($key) . ' = ' . $this->parameter($value); + })->implode(', '); + } + /** * Compile a "where JSON overlaps" clause. */ diff --git a/src/Query/Grammars/MySqlGrammar.php b/src/Query/Grammars/MySqlGrammar.php index 945d9e3..fe929c4 100755 --- a/src/Query/Grammars/MySqlGrammar.php +++ b/src/Query/Grammars/MySqlGrammar.php @@ -92,17 +92,15 @@ public function compileRandom($seed): string /** * Compile an update statement into SQL. - * - * @param array $values */ - public function compileUpdate(Builder $query, $values): string + public function compileUpdate(Builder $query, array $values): string { $table = $this->wrapTable($query->from); // Each one of the columns in the update statements needs to be wrapped in the // keyword identifiers, also a place-holder needs to be created for each of // the values in the list of bindings so we can make the sets statements. - $columns = $this->compileUpdateColumns($values); + $columns = $this->compileUpdateColumns($query, $values); // If the query has any "join" clauses, we will setup the joins on the builder // and compile them so we can attach them to this update, as update queries @@ -288,10 +286,8 @@ protected function compileLock(Builder $query, $value): string /** * Compile all of the columns for an update statement. - * - * @param array $values */ - protected function compileUpdateColumns($values): string + protected function compileUpdateColumns(Builder $query, array $values): string { return collect($values)->map(function ($value, $key) { if ($this->isJsonSelector($key)) {