From 52bcdad90ba7f2e175efeb17f8c0a2322a1deabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20No=C3=ABl?= Date: Wed, 8 Feb 2023 18:09:54 +0100 Subject: [PATCH] Fix JSON field for postgres when the value is a simple string --- packages/core/database/lib/dialects/postgresql/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core/database/lib/dialects/postgresql/index.js b/packages/core/database/lib/dialects/postgresql/index.js index 431f452eaf..b17c03c6ca 100644 --- a/packages/core/database/lib/dialects/postgresql/index.js +++ b/packages/core/database/lib/dialects/postgresql/index.js @@ -16,11 +16,18 @@ class PostgresDialect extends Dialect { } async initialize() { + // Don't cast DATE string to Date() this.db.connection.client.driver.types.setTypeParser( this.db.connection.client.driver.types.builtins.DATE, 'text', (v) => v - ); // Don't cast DATE string to Date() + ); + // Don't parse JSONB automatically + this.db.connection.client.driver.types.setTypeParser( + this.db.connection.client.driver.types.builtins.JSONB, + 'text', + (v) => v + ); this.db.connection.client.driver.types.setTypeParser( this.db.connection.client.driver.types.builtins.NUMERIC, 'text',