diff --git a/packages/core/database/lib/dialects/postgresql/index.js b/packages/core/database/lib/dialects/postgresql/index.js index b17c03c6ca..7066a72e0f 100644 --- a/packages/core/database/lib/dialects/postgresql/index.js +++ b/packages/core/database/lib/dialects/postgresql/index.js @@ -22,12 +22,6 @@ class PostgresDialect extends Dialect { 'text', (v) => v ); - // 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', diff --git a/packages/core/database/lib/fields/json.js b/packages/core/database/lib/fields/json.js index 8872f2ebbd..1fffcdc101 100644 --- a/packages/core/database/lib/fields/json.js +++ b/packages/core/database/lib/fields/json.js @@ -8,7 +8,12 @@ class JSONField extends Field { } fromDB(value) { - if (typeof value === 'string') return JSON.parse(value); + try { + if (typeof value === 'string') return JSON.parse(value); + } catch (error) { + // Just return the value if it's not a valid JSON string + return value; + } return value; } }