Skip to content

Commit

Permalink
simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Kunz committed Aug 29, 2024
1 parent fa7cfec commit c64d4a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions db-service/lib/deep-queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const getDeepQueries = (query, dbData, target) => {
}

const deletes = new Map()
const result = _getDeepQueries(diff, target, true, deletes)
const result = _getDeepQueries(diff, target, deletes)
for (const d of deletes.values()) result.push(d)
return result
}
Expand All @@ -222,7 +222,7 @@ const _hasManagedElements = target => {
* @param {boolean} [root=false]
* @returns {import('@sap/cds/apis/cqn').Query[]}
*/
const _getDeepQueries = (diff, target, root, deletes) => {
const _getDeepQueries = (diff, target, deletes, root = true) => {
const queries = []

for (const diffEntry of diff) {
Expand All @@ -239,7 +239,7 @@ const _getDeepQueries = (diff, target, root, deletes) => {
} else if (target.compositions?.[prop]) {
const arrayed = Array.isArray(propData) ? propData : [propData]
arrayed.forEach(subEntry => {
subQueries.push(..._getDeepQueries([subEntry], target.elements[prop]._target, false, deletes))
subQueries.push(..._getDeepQueries([subEntry], target.elements[prop]._target, deletes, false))
})
delete diffEntry[prop]
} else if (diffEntry[prop] === undefined) {
Expand Down

0 comments on commit c64d4a7

Please sign in to comment.