@strapi/database 5.0.0-beta.11 → 5.0.0-beta.13
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/entity-manager/regular-relations.d.ts.map +1 -1
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -4735,7 +4735,7 @@ const deleteRelatedMorphOneRelationsAfterMorphToManyUpdate = async (rows, {
|
|
|
4735
4735
|
await createQueryBuilder(joinTable.name, db).delete().where({ $or: orWhere }).transacting(trx).execute();
|
|
4736
4736
|
}
|
|
4737
4737
|
};
|
|
4738
|
-
const getDocumentSiblingIdsQuery = (
|
|
4738
|
+
const getDocumentSiblingIdsQuery = (tableName, id) => {
|
|
4739
4739
|
const models = Array.from(strapi.db.metadata.values());
|
|
4740
4740
|
const isContentType = models.find((model) => {
|
|
4741
4741
|
return model.tableName === tableName && model.attributes.documentId;
|
|
@@ -4743,10 +4743,12 @@ const getDocumentSiblingIdsQuery = (con, tableName, id) => {
|
|
|
4743
4743
|
if (!isContentType) {
|
|
4744
4744
|
return [id];
|
|
4745
4745
|
}
|
|
4746
|
-
return con
|
|
4747
|
-
"
|
|
4748
|
-
|
|
4749
|
-
|
|
4746
|
+
return (con) => {
|
|
4747
|
+
con.from(tableName).select("id").where(
|
|
4748
|
+
"document_id",
|
|
4749
|
+
(con2) => con2.select("document_id").from(tableName).where("id", id)
|
|
4750
|
+
);
|
|
4751
|
+
};
|
|
4750
4752
|
};
|
|
4751
4753
|
const deletePreviousOneToAnyRelations = async ({
|
|
4752
4754
|
id,
|
|
@@ -4763,7 +4765,11 @@ const deletePreviousOneToAnyRelations = async ({
|
|
|
4763
4765
|
const { joinTable } = attribute;
|
|
4764
4766
|
const { joinColumn, inverseJoinColumn } = joinTable;
|
|
4765
4767
|
const con = db.getConnection();
|
|
4766
|
-
await con.delete().from(joinTable.name).whereNotIn(
|
|
4768
|
+
await con.delete().from(joinTable.name).whereNotIn(
|
|
4769
|
+
// @ts-expect-error - knex incorrectly expects a string array
|
|
4770
|
+
joinColumn.name,
|
|
4771
|
+
getDocumentSiblingIdsQuery(joinColumn.referencedTable, id)
|
|
4772
|
+
).whereIn(inverseJoinColumn.name, relIdsToadd).where(joinTable.on || {}).transacting(trx);
|
|
4767
4773
|
await cleanOrderColumns({ attribute, db, inverseRelIds: relIdsToadd, transaction: trx });
|
|
4768
4774
|
};
|
|
4769
4775
|
const deletePreviousAnyToOneRelations = async ({
|
|
@@ -4781,8 +4787,9 @@ const deletePreviousAnyToOneRelations = async ({
|
|
|
4781
4787
|
}
|
|
4782
4788
|
if (isManyToAny(attribute)) {
|
|
4783
4789
|
const relsToDelete = await con.select(inverseJoinColumn.name).from(joinTable.name).where(joinColumn.name, id).whereNotIn(
|
|
4790
|
+
// @ts-expect-error - knex incorrectly expects a string array
|
|
4784
4791
|
inverseJoinColumn.name,
|
|
4785
|
-
getDocumentSiblingIdsQuery(
|
|
4792
|
+
getDocumentSiblingIdsQuery(inverseJoinColumn.referencedTable, relIdToadd)
|
|
4786
4793
|
).where(joinTable.on || {}).transacting(trx);
|
|
4787
4794
|
const relIdsToDelete = map(inverseJoinColumn.name, relsToDelete);
|
|
4788
4795
|
await createQueryBuilder(joinTable.name, db).delete().where({
|
|
@@ -4792,8 +4799,9 @@ const deletePreviousAnyToOneRelations = async ({
|
|
|
4792
4799
|
await cleanOrderColumns({ attribute, db, inverseRelIds: relIdsToDelete, transaction: trx });
|
|
4793
4800
|
} else {
|
|
4794
4801
|
await con.delete().from(joinTable.name).where(joinColumn.name, id).whereNotIn(
|
|
4802
|
+
// @ts-expect-error - knex incorrectly expects a string array
|
|
4795
4803
|
inverseJoinColumn.name,
|
|
4796
|
-
getDocumentSiblingIdsQuery(
|
|
4804
|
+
getDocumentSiblingIdsQuery(inverseJoinColumn.referencedTable, relIdToadd)
|
|
4797
4805
|
).where(joinTable.on || {}).transacting(trx);
|
|
4798
4806
|
}
|
|
4799
4807
|
};
|