@strapi/database 5.0.0-rc.1 → 5.0.0-rc.11
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/fields/json.d.ts +1 -1
- package/dist/fields/json.d.ts.map +1 -1
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -4
- package/dist/index.mjs.map +1 -1
- package/dist/metadata/relations.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2557,7 +2557,8 @@ const createJoinTable = (metadata, { attributeName, attribute, meta }) => {
|
|
|
2557
2557
|
column: {
|
|
2558
2558
|
unsigned: true,
|
|
2559
2559
|
defaultTo: null
|
|
2560
|
-
}
|
|
2560
|
+
},
|
|
2561
|
+
columnName: orderColumnName
|
|
2561
2562
|
};
|
|
2562
2563
|
metadataSchema.indexes.push({
|
|
2563
2564
|
name: identifiers.getOrderFkIndexName(joinTableName),
|
|
@@ -2572,7 +2573,8 @@ const createJoinTable = (metadata, { attributeName, attribute, meta }) => {
|
|
|
2572
2573
|
column: {
|
|
2573
2574
|
unsigned: true,
|
|
2574
2575
|
defaultTo: null
|
|
2575
|
-
}
|
|
2576
|
+
},
|
|
2577
|
+
columnName: inverseOrderColumnName
|
|
2576
2578
|
};
|
|
2577
2579
|
metadataSchema.indexes.push({
|
|
2578
2580
|
name: identifiers.getOrderInverseFkIndexName(joinTableName),
|
|
@@ -2743,12 +2745,22 @@ class StringField extends Field {
|
|
|
2743
2745
|
}
|
|
2744
2746
|
class JSONField extends Field {
|
|
2745
2747
|
toDB(value) {
|
|
2746
|
-
|
|
2748
|
+
if (value == null) {
|
|
2749
|
+
return null;
|
|
2750
|
+
}
|
|
2751
|
+
if (typeof value === "object") {
|
|
2752
|
+
return JSON.stringify(value);
|
|
2753
|
+
}
|
|
2754
|
+
return value;
|
|
2747
2755
|
}
|
|
2748
2756
|
fromDB(value) {
|
|
2749
2757
|
try {
|
|
2750
2758
|
if (typeof value === "string") {
|
|
2751
|
-
|
|
2759
|
+
const parsedValue = JSON.parse(value);
|
|
2760
|
+
if (typeof parsedValue === "string") {
|
|
2761
|
+
return JSON.parse(parsedValue);
|
|
2762
|
+
}
|
|
2763
|
+
return parsedValue;
|
|
2752
2764
|
}
|
|
2753
2765
|
} catch (error) {
|
|
2754
2766
|
return value;
|