Merge branch 'fix/windows-import-export' of https://github.com/strapi/strapi into fix/windows-import-export

This commit is contained in:
Ben Irvin 2023-04-18 17:52:18 +02:00
commit de8351ffbe
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;
}
}