Skip to content

Commit d2d8274

Browse files
authored
修复MySQL8下更新JSON字段时出现的字符转换问题
PDOException: SQLSTATE[22032]: <<Unknown error>>: 3144 Cannot create a JSON value from a string with CHARACTER SET 'binary'.
1 parent 14e4be7 commit d2d8274

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Db/Mysql/Query/Builder/UpdateBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function build(...$args): string
7373
{
7474
$jsonSets[$field][] = [
7575
'jsonKeywords' => $matches['jsonKeywords'],
76-
'raw' => 'CONVERT(\'' . json_encode($v, \JSON_THROW_ON_ERROR | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE) . '\',JSON)',
76+
'raw' => 'CAST(\'' . json_encode($v, \JSON_THROW_ON_ERROR | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE) . '\' AS JSON)',
7777
];
7878
}
7979
}

0 commit comments

Comments
 (0)