From d2d827410b7bedd4f6a515ca918aa39d1600518d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=AF=BAEno?= <895183594@qq.com> Date: Thu, 3 Jul 2025 11:30:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMySQL8=E4=B8=8B=E6=9B=B4?= =?UTF-8?q?=E6=96=B0JSON=E5=AD=97=E6=AE=B5=E6=97=B6=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E7=AC=A6=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PDOException: SQLSTATE[22032]: <>: 3144 Cannot create a JSON value from a string with CHARACTER SET 'binary'. --- src/Db/Mysql/Query/Builder/UpdateBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Db/Mysql/Query/Builder/UpdateBuilder.php b/src/Db/Mysql/Query/Builder/UpdateBuilder.php index b8ef5930d..45dbc33df 100644 --- a/src/Db/Mysql/Query/Builder/UpdateBuilder.php +++ b/src/Db/Mysql/Query/Builder/UpdateBuilder.php @@ -73,7 +73,7 @@ public function build(...$args): string { $jsonSets[$field][] = [ 'jsonKeywords' => $matches['jsonKeywords'], - 'raw' => 'CONVERT(\'' . json_encode($v, \JSON_THROW_ON_ERROR | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE) . '\',JSON)', + 'raw' => 'CAST(\'' . json_encode($v, \JSON_THROW_ON_ERROR | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE) . '\' AS JSON)', ]; } }