mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Fix some bugs introduced by the ts migration
This commit is contained in:
parent
af1f80b6e8
commit
5802a65a2d
@ -20,7 +20,7 @@ type Entry = {
|
||||
};
|
||||
|
||||
function isEntry(property: unknown): property is Entry | Entry[] {
|
||||
return isPlainObject(property) || Array.isArray(property);
|
||||
return property === null || isPlainObject(property) || Array.isArray(property);
|
||||
}
|
||||
|
||||
function isDZEntries(property: unknown): property is (Entry & { __component: UID.Component })[] {
|
||||
@ -102,12 +102,7 @@ function transformEntry(
|
||||
const property = properties[key];
|
||||
const attribute = type && type.attributes[key];
|
||||
|
||||
if (
|
||||
attribute &&
|
||||
contentTypeUtils.isRelationalAttribute(attribute) &&
|
||||
isEntry(property) &&
|
||||
'target' in attribute
|
||||
) {
|
||||
if (attribute && attribute.type === 'relation' && isEntry(property) && 'target' in attribute) {
|
||||
const data = transformEntry(
|
||||
property,
|
||||
strapi.contentType(attribute.target as Common.UID.ContentType)
|
||||
|
||||
@ -54,12 +54,14 @@ const transformLoadParamsToQuery = (
|
||||
params: Record<string, unknown>,
|
||||
pagination = {}
|
||||
) => {
|
||||
const transformedParams = transformParamsToQuery(uid, params);
|
||||
const query = transformParamsToQuery(uid, { populate: { [field]: params } as any }) as any;
|
||||
|
||||
return {
|
||||
...(_.get(transformedParams, ['populate', field]) ?? {}),
|
||||
const res = {
|
||||
...query.populate[field],
|
||||
...pagination,
|
||||
};
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
const databaseErrorsToTransform = [
|
||||
@ -417,11 +419,7 @@ const createDefaultImplementation = ({
|
||||
|
||||
const loadedEntity = await db
|
||||
.query(uid)
|
||||
.load(
|
||||
entity,
|
||||
field,
|
||||
transformLoadParamsToQuery(uid, field, params as Record<string, unknown>)
|
||||
);
|
||||
.load(entity, field, transformLoadParamsToQuery(uid, field, params ?? {}));
|
||||
|
||||
return this.wrapResult(loadedEntity, { uid, field, action: 'load' });
|
||||
},
|
||||
@ -438,12 +436,7 @@ const createDefaultImplementation = ({
|
||||
throw new Error(`Invalid load. Expected "${field}" to be an anyToMany relational attribute`);
|
||||
}
|
||||
|
||||
const query = transformLoadParamsToQuery(
|
||||
uid,
|
||||
field,
|
||||
params as Record<string, unknown>,
|
||||
pagination
|
||||
);
|
||||
const query = transformLoadParamsToQuery(uid, field, params ?? {}, pagination);
|
||||
|
||||
const loadedPage: any = await db.query(uid).loadPages(entity, field, query);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user