mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 06:04:29 +00:00
change strictConnect to strict
This commit is contained in:
parent
ca52f1ea78
commit
589571319f
@ -740,12 +740,12 @@ describe('Relations', () => {
|
||||
];
|
||||
const updatedShop = await updateEntry('shop', createdShop.id, {
|
||||
name: 'Cazotte Shop',
|
||||
products_om: { options: { strictConnect: false }, connect: relationToChange },
|
||||
products_mm: { options: { strictConnect: false }, connect: relationToChange },
|
||||
products_mw: { options: { strictConnect: false }, connect: relationToChange },
|
||||
products_om: { options: { strict: false }, connect: relationToChange },
|
||||
products_mm: { options: { strict: false }, connect: relationToChange },
|
||||
products_mw: { options: { strict: false }, connect: relationToChange },
|
||||
myCompo: {
|
||||
id: createdShop.myCompo.id,
|
||||
compo_products_mw: { options: { strictConnect: false }, connect: relationToChange },
|
||||
compo_products_mw: { options: { strict: false }, connect: relationToChange },
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ const toAssocs = (data) => {
|
||||
|
||||
return {
|
||||
options: {
|
||||
strictConnect: data?.options?.strictConnect,
|
||||
strict: data?.options?.strict,
|
||||
},
|
||||
connect: toIdArray(data?.connect).map((elm) => ({
|
||||
id: elm.id,
|
||||
@ -880,7 +880,7 @@ const createEntityManager = (db) => {
|
||||
adjacentRelations,
|
||||
inverseJoinColumn.name,
|
||||
joinTable.orderColumnName,
|
||||
cleanRelationData.options.strictConnect
|
||||
cleanRelationData.options.strict
|
||||
)
|
||||
.connect(cleanRelationData.connect)
|
||||
.getOrderMap();
|
||||
|
||||
@ -117,11 +117,11 @@ const sortConnectArray = (connectArr, initialArr = [], strictSort = true) => {
|
||||
* @param {Array<*>} initArr - array of relations to initialize the class with
|
||||
* @param {string} idColumn - the column name of the id
|
||||
* @param {string} orderColumn - the column name of the order
|
||||
* @param {boolean} strictConnect - if true, will throw an error if a relation is connected adjacent to
|
||||
* @param {boolean} strict - if true, will throw an error if a relation is connected adjacent to
|
||||
* another one that does not exist
|
||||
* @return {*}
|
||||
*/
|
||||
const relationsOrderer = (initArr, idColumn, orderColumn, strictConnect) => {
|
||||
const relationsOrderer = (initArr, idColumn, orderColumn, strict) => {
|
||||
const arr = _.castArray(initArr || []).map((r) => ({
|
||||
init: true,
|
||||
id: r[idColumn],
|
||||
@ -175,7 +175,7 @@ const relationsOrderer = (initArr, idColumn, orderColumn, strictConnect) => {
|
||||
return this;
|
||||
},
|
||||
connect(relations) {
|
||||
const sortedRelations = sortConnectArray(relations, arr, strictConnect);
|
||||
const sortedRelations = sortConnectArray(relations, arr, strict);
|
||||
sortedRelations.forEach((relation) => {
|
||||
this.disconnect(relation);
|
||||
|
||||
|
||||
@ -138,8 +138,10 @@ const createShop = async ({
|
||||
anyToManyRel = [{ id: id1 }, { id: id2 }, { id: id3 }],
|
||||
data = {},
|
||||
populate,
|
||||
strictConnect = true,
|
||||
strict,
|
||||
}) => {
|
||||
const options = strict ? { strict } : {};
|
||||
|
||||
return createEntry(
|
||||
'shops',
|
||||
{
|
||||
@ -147,12 +149,12 @@ const createShop = async ({
|
||||
products_ow: { connect: anyToOneRel },
|
||||
products_oo: { connect: anyToOneRel },
|
||||
products_mo: { connect: anyToOneRel },
|
||||
products_om: { options: { strictConnect }, connect: anyToManyRel },
|
||||
products_mm: { options: { strictConnect }, connect: anyToManyRel },
|
||||
products_mw: { options: { strictConnect }, connect: anyToManyRel },
|
||||
products_om: { options, connect: anyToManyRel },
|
||||
products_mm: { options, connect: anyToManyRel },
|
||||
products_mw: { options, connect: anyToManyRel },
|
||||
myCompo: {
|
||||
compo_products_ow: { connect: anyToOneRel },
|
||||
compo_products_mw: { options: { strictConnect }, connect: anyToManyRel },
|
||||
compo_products_mw: { options, connect: anyToManyRel },
|
||||
},
|
||||
...data,
|
||||
},
|
||||
@ -168,7 +170,7 @@ const updateShop = async (
|
||||
relAction = 'connect',
|
||||
data = {},
|
||||
populate,
|
||||
strictConnect = true,
|
||||
strict = true,
|
||||
}
|
||||
) => {
|
||||
return updateEntry(
|
||||
@ -179,13 +181,13 @@ const updateShop = async (
|
||||
products_ow: { [relAction]: anyToOneRel },
|
||||
products_oo: { [relAction]: anyToOneRel },
|
||||
products_mo: { [relAction]: anyToOneRel },
|
||||
products_om: { options: { strictConnect }, [relAction]: anyToManyRel },
|
||||
products_mm: { options: { strictConnect }, [relAction]: anyToManyRel },
|
||||
products_mw: { options: { strictConnect }, [relAction]: anyToManyRel },
|
||||
products_om: { options: { strict }, [relAction]: anyToManyRel },
|
||||
products_mm: { options: { strict }, [relAction]: anyToManyRel },
|
||||
products_mw: { options: { strict }, [relAction]: anyToManyRel },
|
||||
myCompo: {
|
||||
id: shop.attributes?.myCompo?.id,
|
||||
compo_products_ow: { [relAction]: anyToOneRel },
|
||||
compo_products_mw: { options: { strictConnect }, [relAction]: anyToManyRel },
|
||||
compo_products_mw: { options: { strict }, [relAction]: anyToManyRel },
|
||||
},
|
||||
...data,
|
||||
},
|
||||
@ -877,7 +879,7 @@ describe('Relations', () => {
|
||||
// Connect before an id that does not exist.
|
||||
const updatedShop = await updateShop(shop.data, {
|
||||
anyToManyRel: [{ id: id2, position: { after: id3 } }],
|
||||
strictConnect: false,
|
||||
strict: false,
|
||||
});
|
||||
|
||||
const expectedShop = shopFactory({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user