This commit is contained in:
Adria Navarro 2023-10-11 13:54:51 +02:00
parent fcaf657e53
commit 8fa71e2e1b
1 changed files with 2 additions and 5 deletions

View File

@ -614,7 +614,7 @@ export class ExternalRequest<T extends Operation> {
// @ts-ignore // @ts-ignore
const linkPrimaryKey = this.tables[relatedTableName].primary[0] const linkPrimaryKey = this.tables[relatedTableName].primary[0]
const lookupField = isMany ? primaryKey : (field as any).foreignKey const lookupField = isMany ? primaryKey : field.foreignKey
const fieldName = isMany ? field.throughTo || primaryKey : field.fieldName const fieldName = isMany ? field.throughTo || primaryKey : field.fieldName
if (!lookupField || !row[lookupField]) { if (!lookupField || !row[lookupField]) {
continue continue
@ -629,10 +629,7 @@ export class ExternalRequest<T extends Operation> {
}) })
// this is the response from knex if no rows found // this is the response from knex if no rows found
const rows = !response[0].read ? response : [] const rows = !response[0].read ? response : []
const storeTo = isMany const storeTo = isMany ? field.throughFrom || linkPrimaryKey : fieldName
? (field as ManyToManyRelationshipFieldMetadata).throughFrom ||
linkPrimaryKey
: fieldName
related[storeTo] = { rows, isMany, tableId } related[storeTo] = { rows, isMany, tableId }
} }
return related return related