From b4f4b499b91d38d1874ca61c534497c1371f4d91 Mon Sep 17 00:00:00 2001 From: Convly Date: Thu, 20 Oct 2022 15:32:51 +0200 Subject: [PATCH] Fix a bug that was not automatically adding the join column to the select list when populated --- packages/core/database/lib/query/helpers/populate.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/database/lib/query/helpers/populate.js b/packages/core/database/lib/query/helpers/populate.js index 4c4f23cf9a..4bb8906d9a 100644 --- a/packages/core/database/lib/query/helpers/populate.js +++ b/packages/core/database/lib/query/helpers/populate.js @@ -83,7 +83,13 @@ const processPopulate = (populate, ctx) => { continue; } - // make sure id is present for future populate queries + // Make sure to query the join column value if needed, + // so that we can apply the populate later on + if (attribute.joinColumn) { + qb.addSelect(attribute.joinColumn.name); + } + + // Make sure id is present for future populate queries if (_.has('id', meta.attributes)) { qb.addSelect('id'); }