Json Nullable改为JSON Array
环境
laravel framework 10.10
php 8.1
mysql 8.0
之前数据库字段为json(column)->nullable();
现在想改为json(column)->default(new Expression(‘(JSON_ARRAY())’));
$table->json("xxx")->default(new Expression('(JSON_ARRAY())'))->change();
报错如下
str_replace(): Argument #3 ($subject) must be of type array|string, Illuminate\Database\Query\Expression given
at vendor/doctrine/dbal/src/Platforms/AbstractMySQLPlatform.php:1375
1371▕ * {@inheritDoc}
1372▕ */
1373▕ public function quoteStringLiteral($str)
1374▕ {
➜ 1375▕ $str = str_replace('\\', '\\\\', $str); // MySQL requires backslashes to be escaped
1376▕
1377▕ return parent::quoteStringLiteral($str);
1378▕ }
1379▕
求大佬指点
🤷♂️ 好像是不行
随便搜了一下,没有测试,应该这样就可以了吧