Skip to content

Commit

Permalink
always rewrite to path expression on new db
Browse files Browse the repository at this point in the history
  • Loading branch information
sjvans committed Nov 28, 2024
1 parent 4895ccc commit 1bff617
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1bff617

Please sign in to comment.