From 924ef7cc8ecc162c53a485001689332de5b9cf6c Mon Sep 17 00:00:00 2001 From: akaJes Date: Fri, 18 Feb 2022 16:41:23 +0200 Subject: [PATCH] remove errors for joins option "errors": [ { "message": "Cannot read property 'associations' of undefined", AND "errors": [ { "message": "FIELD is associated to TABLE using an alias. You must use the 'as' keyword to specify the alias within your include statement.", --- src/utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils.js b/src/utils.js index 0ba784c..8090521 100644 --- a/src/utils.js +++ b/src/utils.js @@ -133,7 +133,8 @@ const getIncludes = (ast, modelName, models) => { model: associations[key].target, required: join === 'INNER', right: join === 'RIGHT', - include: fieldsAst ? getIncludes(fieldsAst, key, models) : [] + as: key, + include: fieldsAst ? getIncludes(fieldsAst, associations[key].target.name, models) : [] }); includes.push(include); @@ -191,4 +192,4 @@ module.exports = { getIncludes, getOrderBy, keysWhichAreModelAssociations -}; \ No newline at end of file +};