@strapi/database 5.0.0-rc.5 → 5.0.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2743,12 +2743,22 @@ class StringField extends Field {
2743
2743
  }
2744
2744
  class JSONField extends Field {
2745
2745
  toDB(value) {
2746
- return JSON.stringify(value);
2746
+ if (value == null) {
2747
+ return null;
2748
+ }
2749
+ if (typeof value === "object") {
2750
+ return JSON.stringify(value);
2751
+ }
2752
+ return value;
2747
2753
  }
2748
2754
  fromDB(value) {
2749
2755
  try {
2750
2756
  if (typeof value === "string") {
2751
- return JSON.parse(value);
2757
+ const parsedValue = JSON.parse(value);
2758
+ if (typeof parsedValue === "string") {
2759
+ return JSON.parse(parsedValue);
2760
+ }
2761
+ return parsedValue;
2752
2762
  }
2753
2763
  } catch (error) {
2754
2764
  return value;