diff --git a/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php b/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php index 168f02b45370..7ed47abef4df 100755 --- a/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php +++ b/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php @@ -169,7 +169,8 @@ public function prepareBindingsForUpdate(array $bindings, array $values) $index = 0; foreach ($values as $column => $value) { - if ($this->isJsonSelector($column) && is_bool($value)) { + if ($this->isJsonSelector($column) && + in_array(gettype($value), ['boolean', 'integer', 'double'])) { unset($bindings[$index]); } diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index fb7a1ae2e826..82bb4aca20f9 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -1385,10 +1385,17 @@ public function testMySqlUpdateWithJsonRemovesBindingsCorrectly() 'update `users` set `options` = json_set(`options`, "$.enable", false), `updated_at` = ? where `id` = ?', ['2015-05-26 22:02:06', 0] ); - $builder = new Builder($connection, $grammar, $processor); + $builder->from('users')->where('id', '=', 0)->update(['options->enable' => false, 'updated_at' => '2015-05-26 22:02:06']); - $result = $builder->from('users')->where('id', '=', 0)->update(['options->enable' => false, 'updated_at' => '2015-05-26 22:02:06']); + $connection->shouldReceive('update') + ->once() + ->with( + 'update `users` set `options` = json_set(`options`, "$.size", 45), `updated_at` = ? where `id` = ?', + ['2015-05-26 22:02:06', 0] + ); + $builder = new Builder($connection, $grammar, $processor); + $builder->from('users')->where('id', '=', 0)->update(['options->size' => 45, 'updated_at' => '2015-05-26 22:02:06']); } public function testMySqlWrappingJsonWithString()