From 1bff617f971a938825f252591fd3407905c1a715 Mon Sep 17 00:00:00 2001 From: D050513 Date: Thu, 28 Nov 2024 14:32:35 +0100 Subject: [PATCH] always rewrite to path expression on new db --- lib/utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index d3b0df5..cfb81b3 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -123,8 +123,10 @@ const _buildSubSelect = (model, { entity, relative, element, next }, row, previo let w = relative._relations[element.name].join(targetAlias, relativeAlias) + const NEW_DB = cds.env.requires.db.impl?.startsWith('@cap-js') + // REVISIT: rewrite to path expression, if alias for relative is already used in subselect to avoid sql error - if (previousCqn?._aliases.has(relativeAlias)) { + if (NEW_DB || previousCqn?._aliases.has(relativeAlias)) { let t for (const a in entity.associations) if (entity.associations[a].target === relative.name) t = entity.associations[a] if (t && w[0]?.xpr) for (const ele of w[0].xpr) if (ele.ref?.[0] === relativeAlias) ele.ref.splice(0, 1, as, t.name)