From ff954d8680b997d931d14ff5224678521693acaa Mon Sep 17 00:00:00 2001 From: anthioikonomou Date: Thu, 24 Oct 2024 10:09:19 +0300 Subject: [PATCH] Ignore property if model association is not defined --- select-object-query.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/select-object-query.js b/select-object-query.js index 1eacbb5..6ed9903 100644 --- a/select-object-query.js +++ b/select-object-query.js @@ -83,9 +83,12 @@ class SelectObjectQuery { // otherwise, if this property is an association if (isObjectDeep(value)) { // assign associated key value (event.g. primary key value) - Object.assign(prev, { - [name]: value[mapping.parentField] - }); + // ignore property if model doesn't have an association with it + if (mapping) { + Object.assign(prev, { + [name]: value[mapping.parentField] + }); + } } else { Object.assign(prev, { [name]: value