Skip to content

Commit

Permalink
backlink name + all necessary assocs must be in projection
Browse files Browse the repository at this point in the history
  • Loading branch information
sjvans committed Dec 13, 2024
1 parent 2692475 commit 44d61c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,16 @@ const _getRelation = (left, right, abort) => {
break
}
}
if (a) return { base: left, target: right, assoc: a }
if (a) {
let backlink
for (const assoc in right.associations) {
if (right.associations[assoc].target === left.name) {
backlink = right.associations[assoc]
break
}
}
return { base: left, target: right, assoc: a, backlink }
}
return abort ? undefined : _getRelation(right, left, true)
}

Expand Down Expand Up @@ -195,7 +204,7 @@ const _new_getDataSubjectIdQuery = ({ dataSubjectEntity, subs }, row) => {
path.push({ to: relation.assoc.name })
} else {
// backwards
path[0].id = s.element.name
path[0].id = relation.backlink?.name || s.element.name
path.unshift({ id: relation.target.name })
}
} else {
Expand Down Expand Up @@ -341,7 +350,11 @@ const resolveDataSubjects = (logs, req) => {
if (each.data_subject.id instanceof cds.ql.Query) {
const q = each.data_subject.id
if (!map.has(q)) {
const p = cds.run(q).then(res => map.set(q, res))
const p = cds.run(q).then(res => map.set(q, res)).catch(err => {
q
debugger
throw err
})
map.set(q, p)
ps.push(p)
}
Expand Down
1 change: 1 addition & 0 deletions test/personal-data-complex/srv/crud-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ service CollaborationsService @(path: '/collaborations') {
employeeNav,
validTo,
eventAssignments,
collaborations
};

@cds.redirection.target
Expand Down

0 comments on commit 44d61c8

Please sign in to comment.