Skip to content

Commit 7f48342

Browse files
authored
fix: no logs for non-modifying queries (#121)
supersedes #118
1 parent d56e73c commit 7f48342

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
99
### Fixed
1010

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

1314
## Version 0.8.1 - 2024-09-13
1415

lib/modification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const addDiffToCtx = async function (req) {
7676
if (!_audit.diffs) _audit.diffs = new Map()
7777

7878
// get diff
79-
let diff = await req.diff()
79+
let diff = (await req.diff()) || {}
8080
diff = _getDataWithAppliedTransitions(diff, req)
8181

8282
// add keys, if necessary

test/personal-data/crud.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,18 @@ describe('personal data audit logging in CRUD', () => {
12921292
})
12931293
})
12941294

1295+
test('delete non existing entity does not cause any logs', async () => {
1296+
const { Pages } = cds.entities('CRUD_1')
1297+
await cds.delete(Pages).where(`ID = 123456789`)
1298+
1299+
expect(_logs).not.toContainMatchObject({
1300+
object: {
1301+
type: 'CRUD_1.Pages',
1302+
id: { ID: 123456789 }
1303+
}
1304+
})
1305+
})
1306+
12951307
test('delete Pages with integers - flat', async () => {
12961308
await DELETE('/crud-1/Pages(1)', { auth: ALICE })
12971309

0 commit comments

Comments
 (0)