Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/modification.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ const addDiffToCtx = async function (req) {

// get diff
let diff = await req.diff()
// //Defaulting to an empty object in cases where no diff exists
// This happens when a DELETE or UPDATE has a where clause but does not DELETE or UPDATE anything
diff ??= {};
diff = _getDataWithAppliedTransitions(diff, req)

// add keys, if necessary
Expand Down
12 changes: 12 additions & 0 deletions test/personal-data/crud.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,18 @@ describe('personal data audit logging in CRUD', () => {
})
})

test('delete non existing entity does not cause any logs', async () => {
const {Pages} = cds.entities('CRUD_1');
await cds.delete(Pages).where(`ID = 123456789`);

expect(_logs).not.toContainMatchObject({
object: {
type: 'CRUD_1.Pages',
id: { ID: 123456789 }
}
})
});

test('delete Pages with integers - flat', async () => {
await DELETE('/crud-1/Pages(1)', { auth: ALICE })

Expand Down
Loading