From 110dcd335a7d55a0ab053efbe0bc20585fab7bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=B8=8FYaskur=20Dyas=E2=9A=94=E2=9A=94=EF=B8=8F=E2=9A=94?= Date: Tue, 14 Jan 2025 05:15:46 +0700 Subject: [PATCH] fix: cannot update on JSON column in MariaDB and PostgreSQL --- src/main/ipc-handlers/tables.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/ipc-handlers/tables.ts b/src/main/ipc-handlers/tables.ts index bd1b50c9..8d7bbea7 100644 --- a/src/main/ipc-handlers/tables.ts +++ b/src/main/ipc-handlers/tables.ts @@ -235,12 +235,24 @@ export default (connections: Record) => { if (typeof orgRow[key] === 'string') orgRow[key] = `'${orgRow[key]}'`; else if (typeof orgRow[key] === 'object') { - orgRow[key] = `CAST('${JSON.stringify(orgRow[key])}' AS JSON)`; + switch (connections[params.uid]._client) { + case 'mysql': + orgRow[key] = `CAST('${JSON.stringify(orgRow[key])}' AS JSON)`; + break; + case 'maria': + orgRow[key] = `'${JSON.stringify(orgRow[key])}'`; + break; + case 'pg': + orgRow[key] = `::text='${JSON.stringify(orgRow[key])}'`; + break; + case 'firebird': + case 'sqlite': + } } if (orgRow[key] === null) orgRow[key] = `IS ${orgRow[key]}`; - else + else if (!String(orgRow[key]).includes('::text=')) orgRow[key] = `= ${orgRow[key]}`; }