@strapi/database 5.4.2 → 5.5.0
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 +10 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -20,8 +20,7 @@ const assert = require("assert");
|
|
|
20
20
|
const knex = require("knex");
|
|
21
21
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
22
22
|
function _interopNamespace(e) {
|
|
23
|
-
if (e && e.__esModule)
|
|
24
|
-
return e;
|
|
23
|
+
if (e && e.__esModule) return e;
|
|
25
24
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
26
25
|
if (e) {
|
|
27
26
|
for (const k in e) {
|
|
@@ -4924,10 +4923,8 @@ const encodePolymorphicRelation = _.curry(({ idColumn, typeColumn }, relation) =
|
|
|
4924
4923
|
const { before, after } = relation.position;
|
|
4925
4924
|
const __type = relation.position.__type || relation.__type;
|
|
4926
4925
|
newRelation.position = { ...relation.position };
|
|
4927
|
-
if (before)
|
|
4928
|
-
|
|
4929
|
-
if (after)
|
|
4930
|
-
newRelation.position.after = encodePolymorphicId(after, __type);
|
|
4926
|
+
if (before) newRelation.position.before = encodePolymorphicId(before, __type);
|
|
4927
|
+
if (after) newRelation.position.after = encodePolymorphicId(after, __type);
|
|
4931
4928
|
}
|
|
4932
4929
|
return newRelation;
|
|
4933
4930
|
});
|
|
@@ -5075,8 +5072,7 @@ const cleanOrderColumns = async ({
|
|
|
5075
5072
|
}
|
|
5076
5073
|
};
|
|
5077
5074
|
const updateInverseOrderColumn = async () => {
|
|
5078
|
-
if (!hasInverseOrderColumn(attribute) || _.isEmpty(inverseRelIds))
|
|
5079
|
-
return;
|
|
5075
|
+
if (!hasInverseOrderColumn(attribute) || _.isEmpty(inverseRelIds)) return;
|
|
5080
5076
|
const selectRowsToOrder = (joinTableName) => db.connection(joinTableName).select("id").rowNumber("inv_order", inverseOrderColumnName, inverseJoinColumn.name).where(inverseJoinColumn.name, "in", inverseRelIds).toSQL();
|
|
5081
5077
|
switch (strapi.db.dialect.client) {
|
|
5082
5078
|
case "mysql": {
|
|
@@ -5132,8 +5128,7 @@ const sortConnectArray = (connectArr, initialArr = [], strictSort = true) => {
|
|
|
5132
5128
|
},
|
|
5133
5129
|
{}
|
|
5134
5130
|
);
|
|
5135
|
-
if (!needsSorting)
|
|
5136
|
-
return connectArr;
|
|
5131
|
+
if (!needsSorting) return connectArr;
|
|
5137
5132
|
const computeRelation = (relation, relationsSeenInBranch) => {
|
|
5138
5133
|
const adjacentRelId = relation.position?.before || relation.position?.after;
|
|
5139
5134
|
const adjacentRelation = mappedRelations[adjacentRelId];
|
|
@@ -5241,8 +5236,7 @@ const relationsOrderer = (initArr, idColumn, orderColumn, strict) => {
|
|
|
5241
5236
|
getOrderMap() {
|
|
5242
5237
|
return ___default$1.default(computedRelations).groupBy("order").reduce(
|
|
5243
5238
|
(acc, relations) => {
|
|
5244
|
-
if (relations[0]?.init)
|
|
5245
|
-
return acc;
|
|
5239
|
+
if (relations[0]?.init) return acc;
|
|
5246
5240
|
relations.forEach((relation, idx) => {
|
|
5247
5241
|
acc[relation.id] = Math.floor(relation.order) + (idx + 1) / (relations.length + 1);
|
|
5248
5242
|
});
|
|
@@ -5921,8 +5915,7 @@ const createEntityManager = (db) => {
|
|
|
5921
5915
|
const isPartialUpdate = !_.has("set", cleanRelationData);
|
|
5922
5916
|
let relIdsToaddOrMove;
|
|
5923
5917
|
if (isPartialUpdate) {
|
|
5924
|
-
if (isAnyToOne(attribute))
|
|
5925
|
-
;
|
|
5918
|
+
if (isAnyToOne(attribute)) ;
|
|
5926
5919
|
relIdsToaddOrMove = toIds(cleanRelationData.connect);
|
|
5927
5920
|
const relIdsToDelete = toIds(
|
|
5928
5921
|
_.differenceWith(
|
|
@@ -6110,8 +6103,7 @@ const createEntityManager = (db) => {
|
|
|
6110
6103
|
}
|
|
6111
6104
|
continue;
|
|
6112
6105
|
}
|
|
6113
|
-
if (attribute.relation === "morphToOne")
|
|
6114
|
-
;
|
|
6106
|
+
if (attribute.relation === "morphToOne") ;
|
|
6115
6107
|
if (attribute.relation === "morphToMany") {
|
|
6116
6108
|
const { joinTable } = attribute;
|
|
6117
6109
|
const { joinColumn } = joinTable;
|
|
@@ -6907,8 +6899,7 @@ const getLinksWithoutMappedBy = (db) => {
|
|
|
6907
6899
|
};
|
|
6908
6900
|
const isLinkTableEmpty = async (db, linkTableName) => {
|
|
6909
6901
|
const exists = await db.getSchemaConnection().hasTable(linkTableName);
|
|
6910
|
-
if (!exists)
|
|
6911
|
-
return true;
|
|
6902
|
+
if (!exists) return true;
|
|
6912
6903
|
const result = await db.getConnection().from(linkTableName).count("* as count");
|
|
6913
6904
|
return Number(result[0].count) === 0;
|
|
6914
6905
|
};
|
|
@@ -6935,8 +6926,7 @@ const validateBidirectionalRelations = async (db) => {
|
|
|
6935
6926
|
process.emitWarning(
|
|
6936
6927
|
`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}" }`
|
|
6937
6928
|
);
|
|
6938
|
-
} else
|
|
6939
|
-
;
|
|
6929
|
+
} else ;
|
|
6940
6930
|
}
|
|
6941
6931
|
};
|
|
6942
6932
|
const validateRelations = async (db) => {
|