[13.x] Fix updating JSON paths with arrays and collections on MySQL and MariaDB

Merged
XU
8d ago
+58-2

Updating a JSON path with an array fails on MariaDB, and with a collection it's saved as a string on MySQL and MariaDB:

DB::table('users')->update(['settings->tags' => ['laravel', 'php']]);
// MariaDB: 1064 ... near 'json))'

DB::table('users')->update(['settings->tags' => collect(['laravel', 'php'])]);
// {"tags": "[\"laravel\",\"php\"]"}