Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ protected function compileUpdateWithJoinsOrLimit(Builder $query, array $values)
*/
public function prepareBindingsForUpdate(array $bindings, array $values)
{
$values = collect($values)->map(function ($value) {
return is_array($value) ? json_encode($value) : $value;
})->all();

$cleanBindings = Arr::except($bindings, 'select');

return array_values(
Expand Down
16 changes: 16 additions & 0 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2461,6 +2461,22 @@ public function testPostgresUpdateWrappingJsonArray()
]);
}

public function testSQLiteUpdateWrappingJsonArray()
{
$builder = $this->getSQLiteBuilder();
$builder->getConnection()->shouldReceive('update')
->with('update "users" set "options" = ?, "group_id" = 45, "created_at" = ?', [
json_encode(['2fa' => false, 'presets' => ['laravel', 'vue']]),
new DateTime('2019-08-06'),
]);

$builder->from('users')->update([
'options' => ['2fa' => false, 'presets' => ['laravel', 'vue']],
'group_id' => new Raw('45'),
'created_at' => new DateTime('2019-08-06'),
]);
}

public function testMySqlWrappingJsonWithString()
{
$builder = $this->getMySqlBuilder();
Expand Down