Merge branch 'main' into fix/date-time-picker-crash-delete-date-cleaned

This commit is contained in:
Simone 2023-04-18 17:50:22 +02:00 committed by GitHub
commit 5b60ac513d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -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',

View File

@ -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;
}
}