Skip to content

Commit

Permalink
fix: no logs for non-modifying queries (#121)
Browse files Browse the repository at this point in the history
supersedes #118
  • Loading branch information
sjvans authored Oct 25, 2024
1 parent d56e73c commit 7f48342
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
### Fixed

- Erroneous modification log for non-updated key properties
- Error during non-modifying queries on database level

## Version 0.8.1 - 2024-09-13

Expand Down
2 changes: 1 addition & 1 deletion lib/modification.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const addDiffToCtx = async function (req) {
if (!_audit.diffs) _audit.diffs = new Map()

// get diff
let diff = await req.diff()
let diff = (await req.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 @@ -1292,6 +1292,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

0 comments on commit 7f48342

Please sign in to comment.