@strapi/database 5.4.2 → 5.5.1
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.js +12 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -7
package/dist/index.mjs
CHANGED
|
@@ -4891,10 +4891,8 @@ const encodePolymorphicRelation = curry(({ idColumn, typeColumn }, relation) =>
|
|
|
4891
4891
|
const { before, after } = relation.position;
|
|
4892
4892
|
const __type = relation.position.__type || relation.__type;
|
|
4893
4893
|
newRelation.position = { ...relation.position };
|
|
4894
|
-
if (before)
|
|
4895
|
-
|
|
4896
|
-
if (after)
|
|
4897
|
-
newRelation.position.after = encodePolymorphicId(after, __type);
|
|
4894
|
+
if (before) newRelation.position.before = encodePolymorphicId(before, __type);
|
|
4895
|
+
if (after) newRelation.position.after = encodePolymorphicId(after, __type);
|
|
4898
4896
|
}
|
|
4899
4897
|
return newRelation;
|
|
4900
4898
|
});
|
|
@@ -5042,8 +5040,7 @@ const cleanOrderColumns = async ({
|
|
|
5042
5040
|
}
|
|
5043
5041
|
};
|
|
5044
5042
|
const updateInverseOrderColumn = async () => {
|
|
5045
|
-
if (!hasInverseOrderColumn(attribute) || isEmpty(inverseRelIds))
|
|
5046
|
-
return;
|
|
5043
|
+
if (!hasInverseOrderColumn(attribute) || isEmpty(inverseRelIds)) return;
|
|
5047
5044
|
const selectRowsToOrder = (joinTableName) => db.connection(joinTableName).select("id").rowNumber("inv_order", inverseOrderColumnName, inverseJoinColumn.name).where(inverseJoinColumn.name, "in", inverseRelIds).toSQL();
|
|
5048
5045
|
switch (strapi.db.dialect.client) {
|
|
5049
5046
|
case "mysql": {
|
|
@@ -5099,8 +5096,7 @@ const sortConnectArray = (connectArr, initialArr = [], strictSort = true) => {
|
|
|
5099
5096
|
},
|
|
5100
5097
|
{}
|
|
5101
5098
|
);
|
|
5102
|
-
if (!needsSorting)
|
|
5103
|
-
return connectArr;
|
|
5099
|
+
if (!needsSorting) return connectArr;
|
|
5104
5100
|
const computeRelation = (relation, relationsSeenInBranch) => {
|
|
5105
5101
|
const adjacentRelId = relation.position?.before || relation.position?.after;
|
|
5106
5102
|
const adjacentRelation = mappedRelations[adjacentRelId];
|
|
@@ -5208,8 +5204,7 @@ const relationsOrderer = (initArr, idColumn, orderColumn, strict2) => {
|
|
|
5208
5204
|
getOrderMap() {
|
|
5209
5205
|
return _$1(computedRelations).groupBy("order").reduce(
|
|
5210
5206
|
(acc, relations) => {
|
|
5211
|
-
if (relations[0]?.init)
|
|
5212
|
-
return acc;
|
|
5207
|
+
if (relations[0]?.init) return acc;
|
|
5213
5208
|
relations.forEach((relation, idx) => {
|
|
5214
5209
|
acc[relation.id] = Math.floor(relation.order) + (idx + 1) / (relations.length + 1);
|
|
5215
5210
|
});
|
|
@@ -5559,8 +5554,8 @@ const createEntityManager = (db) => {
|
|
|
5559
5554
|
// Always make a strict connect when inserting
|
|
5560
5555
|
).connect(
|
|
5561
5556
|
// Merge id & __type to get a single id key
|
|
5562
|
-
dataset.map(encodePolymorphicRelation({ idColumn: "id", typeColumn:
|
|
5563
|
-
).get().reduce((acc, rel, idx) => ({ ...acc, [rel.id]: idx }), {});
|
|
5557
|
+
dataset.map(encodePolymorphicRelation({ idColumn: "id", typeColumn: typeField }))
|
|
5558
|
+
).get().reduce((acc, rel, idx) => ({ ...acc, [rel.id]: idx + 1 }), {});
|
|
5564
5559
|
rows.forEach((row) => {
|
|
5565
5560
|
const rowId = row[morphColumn.idColumn.name];
|
|
5566
5561
|
const rowType = row[morphColumn.typeColumn.name];
|
|
@@ -5888,8 +5883,7 @@ const createEntityManager = (db) => {
|
|
|
5888
5883
|
const isPartialUpdate = !has("set", cleanRelationData);
|
|
5889
5884
|
let relIdsToaddOrMove;
|
|
5890
5885
|
if (isPartialUpdate) {
|
|
5891
|
-
if (isAnyToOne(attribute))
|
|
5892
|
-
;
|
|
5886
|
+
if (isAnyToOne(attribute)) ;
|
|
5893
5887
|
relIdsToaddOrMove = toIds(cleanRelationData.connect);
|
|
5894
5888
|
const relIdsToDelete = toIds(
|
|
5895
5889
|
differenceWith(
|
|
@@ -6077,8 +6071,7 @@ const createEntityManager = (db) => {
|
|
|
6077
6071
|
}
|
|
6078
6072
|
continue;
|
|
6079
6073
|
}
|
|
6080
|
-
if (attribute.relation === "morphToOne")
|
|
6081
|
-
;
|
|
6074
|
+
if (attribute.relation === "morphToOne") ;
|
|
6082
6075
|
if (attribute.relation === "morphToMany") {
|
|
6083
6076
|
const { joinTable } = attribute;
|
|
6084
6077
|
const { joinColumn } = joinTable;
|
|
@@ -6874,8 +6867,7 @@ const getLinksWithoutMappedBy = (db) => {
|
|
|
6874
6867
|
};
|
|
6875
6868
|
const isLinkTableEmpty = async (db, linkTableName) => {
|
|
6876
6869
|
const exists = await db.getSchemaConnection().hasTable(linkTableName);
|
|
6877
|
-
if (!exists)
|
|
6878
|
-
return true;
|
|
6870
|
+
if (!exists) return true;
|
|
6879
6871
|
const result = await db.getConnection().from(linkTableName).count("* as count");
|
|
6880
6872
|
return Number(result[0].count) === 0;
|
|
6881
6873
|
};
|
|
@@ -6902,8 +6894,7 @@ const validateBidirectionalRelations = async (db) => {
|
|
|
6902
6894
|
process.emitWarning(
|
|
6903
6895
|
`Error on attribute "${relation.inversedBy}" in model "${invModelMetadata.singularName}" (${invModelMetadata.uid}). Please modify your ${invModelMetadata.singularName} schema by renaming the key "inversedBy" to "mappedBy". Ex: { "inversedBy": "${invRelation.inversedBy}" } -> { "mappedBy": "${invRelation.inversedBy}" }`
|
|
6904
6896
|
);
|
|
6905
|
-
} else
|
|
6906
|
-
;
|
|
6897
|
+
} else ;
|
|
6907
6898
|
}
|
|
6908
6899
|
};
|
|
6909
6900
|
const validateRelations = async (db) => {
|