@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regular-relations.d.ts","sourceRoot":"","sources":["../../src/entity-manager/regular-relations.ts"],"names":[],"mappings":";;;;;AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAYjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAS,MAAM,UAAU,CAAC;AAEpD,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,IAAI,CAAC;QACb,UAAU,kBAAkB;YAC1B,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;SAC3C;KACF;CACF;
|
|
1
|
+
{"version":3,"file":"regular-relations.d.ts","sourceRoot":"","sources":["../../src/entity-manager/regular-relations.ts"],"names":[],"mappings":";;;;;AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAYjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAS,MAAM,UAAU,CAAC;AAEpD,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,IAAI,CAAC;QACb,UAAU,kBAAkB;YAC1B,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;SAC3C;KACF;CACF;AA6BD;;GAEG;AACH,QAAA,MAAM,+BAA+B,0DAMlC;IACD,EAAE,EAAE,EAAE,CAAC;IACP,SAAS,EAAE,SAAS,aAAa,CAAC;IAClC,WAAW,EAAE,EAAE,EAAE,CAAC;IAClB,EAAE,EAAE,QAAQ,CAAC;IACb,WAAW,CAAC,EAAE,KAAK,WAAW,CAAC;CAChC,kBA0BA,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,+BAA+B,yDAMlC;IACD,EAAE,EAAE,EAAE,CAAC;IACP,SAAS,EAAE,SAAS,aAAa,CAAC;IAClC,UAAU,EAAE,EAAE,CAAC;IACf,EAAE,EAAE,QAAQ,CAAC;IACb,WAAW,CAAC,EAAE,KAAK,WAAW,CAAC;CAChC,kBAoDA,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,eAAe,gFAOlB;IACD,EAAE,EAAE,EAAE,CAAC;IACP,SAAS,EAAE,SAAS,aAAa,CAAC;IAClC,EAAE,EAAE,QAAQ,CAAC;IACb,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC;IACzB,cAAc,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;IAC9B,WAAW,CAAC,EAAE,KAAK,WAAW,CAAC;CAChC,kBAsDA,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,iBAAiB,4DAMpB;IACD,EAAE,CAAC,EAAE,EAAE,CAAC;IACR,SAAS,EAAE,SAAS,aAAa,CAAC;IAClC,EAAE,EAAE,QAAQ,CAAC;IACb,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,KAAK,WAAW,CAAC;CAChC,sCAiIA,CAAC;AAEF,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,EAC/B,eAAe,EACf,iBAAiB,GAClB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4767,7 +4767,7 @@ const deleteRelatedMorphOneRelationsAfterMorphToManyUpdate = async (rows, {
|
|
|
4767
4767
|
await createQueryBuilder(joinTable.name, db).delete().where({ $or: orWhere }).transacting(trx).execute();
|
|
4768
4768
|
}
|
|
4769
4769
|
};
|
|
4770
|
-
const getDocumentSiblingIdsQuery = (
|
|
4770
|
+
const getDocumentSiblingIdsQuery = (tableName, id) => {
|
|
4771
4771
|
const models = Array.from(strapi.db.metadata.values());
|
|
4772
4772
|
const isContentType = models.find((model) => {
|
|
4773
4773
|
return model.tableName === tableName && model.attributes.documentId;
|
|
@@ -4775,10 +4775,12 @@ const getDocumentSiblingIdsQuery = (con, tableName, id) => {
|
|
|
4775
4775
|
if (!isContentType) {
|
|
4776
4776
|
return [id];
|
|
4777
4777
|
}
|
|
4778
|
-
return con
|
|
4779
|
-
"
|
|
4780
|
-
|
|
4781
|
-
|
|
4778
|
+
return (con) => {
|
|
4779
|
+
con.from(tableName).select("id").where(
|
|
4780
|
+
"document_id",
|
|
4781
|
+
(con2) => con2.select("document_id").from(tableName).where("id", id)
|
|
4782
|
+
);
|
|
4783
|
+
};
|
|
4782
4784
|
};
|
|
4783
4785
|
const deletePreviousOneToAnyRelations = async ({
|
|
4784
4786
|
id,
|
|
@@ -4795,7 +4797,11 @@ const deletePreviousOneToAnyRelations = async ({
|
|
|
4795
4797
|
const { joinTable } = attribute;
|
|
4796
4798
|
const { joinColumn, inverseJoinColumn } = joinTable;
|
|
4797
4799
|
const con = db.getConnection();
|
|
4798
|
-
await con.delete().from(joinTable.name).whereNotIn(
|
|
4800
|
+
await con.delete().from(joinTable.name).whereNotIn(
|
|
4801
|
+
// @ts-expect-error - knex incorrectly expects a string array
|
|
4802
|
+
joinColumn.name,
|
|
4803
|
+
getDocumentSiblingIdsQuery(joinColumn.referencedTable, id)
|
|
4804
|
+
).whereIn(inverseJoinColumn.name, relIdsToadd).where(joinTable.on || {}).transacting(trx);
|
|
4799
4805
|
await cleanOrderColumns({ attribute, db, inverseRelIds: relIdsToadd, transaction: trx });
|
|
4800
4806
|
};
|
|
4801
4807
|
const deletePreviousAnyToOneRelations = async ({
|
|
@@ -4813,8 +4819,9 @@ const deletePreviousAnyToOneRelations = async ({
|
|
|
4813
4819
|
}
|
|
4814
4820
|
if (isManyToAny(attribute)) {
|
|
4815
4821
|
const relsToDelete = await con.select(inverseJoinColumn.name).from(joinTable.name).where(joinColumn.name, id).whereNotIn(
|
|
4822
|
+
// @ts-expect-error - knex incorrectly expects a string array
|
|
4816
4823
|
inverseJoinColumn.name,
|
|
4817
|
-
getDocumentSiblingIdsQuery(
|
|
4824
|
+
getDocumentSiblingIdsQuery(inverseJoinColumn.referencedTable, relIdToadd)
|
|
4818
4825
|
).where(joinTable.on || {}).transacting(trx);
|
|
4819
4826
|
const relIdsToDelete = _.map(inverseJoinColumn.name, relsToDelete);
|
|
4820
4827
|
await createQueryBuilder(joinTable.name, db).delete().where({
|
|
@@ -4824,8 +4831,9 @@ const deletePreviousAnyToOneRelations = async ({
|
|
|
4824
4831
|
await cleanOrderColumns({ attribute, db, inverseRelIds: relIdsToDelete, transaction: trx });
|
|
4825
4832
|
} else {
|
|
4826
4833
|
await con.delete().from(joinTable.name).where(joinColumn.name, id).whereNotIn(
|
|
4834
|
+
// @ts-expect-error - knex incorrectly expects a string array
|
|
4827
4835
|
inverseJoinColumn.name,
|
|
4828
|
-
getDocumentSiblingIdsQuery(
|
|
4836
|
+
getDocumentSiblingIdsQuery(inverseJoinColumn.referencedTable, relIdToadd)
|
|
4829
4837
|
).where(joinTable.on || {}).transacting(trx);
|
|
4830
4838
|
}
|
|
4831
4839
|
};
|