@sap/cds 9.5.1 → 9.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/libx/_runtime/common/generic/assert.js +28 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
- The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
5
5
|
- This project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## Version 9.5.2 - 2025-12-09
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Usage of associations in `@assert`
|
|
12
|
+
- Usage of `@assert` on child entities
|
|
13
|
+
- Mocking of remote services using `srv.post('<url>')`
|
|
14
|
+
|
|
7
15
|
## Version 9.5.1 - 2025-12-01
|
|
8
16
|
|
|
9
17
|
### Fixed
|
|
@@ -20,19 +20,35 @@ const _bufferReviver = (key, value) => {
|
|
|
20
20
|
return value
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const _hasAssert = entity => {
|
|
24
|
+
if ($has_asserts in entity) return entity[$has_asserts]
|
|
25
|
+
|
|
26
|
+
entity[$has_asserts] = false
|
|
27
|
+
for (const each in entity.elements) {
|
|
28
|
+
const element = entity.elements[each]
|
|
29
|
+
if (element['@assert']) {
|
|
30
|
+
entity[$has_asserts] = true
|
|
31
|
+
break
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (entity[$has_asserts]) return entity[$has_asserts]
|
|
36
|
+
|
|
37
|
+
for (const c in entity.compositions) {
|
|
38
|
+
const nested_asserts = _hasAssert(entity.compositions[c]._target)
|
|
39
|
+
if (nested_asserts) {
|
|
40
|
+
entity[$has_asserts] = true
|
|
41
|
+
break
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return entity[$has_asserts]
|
|
46
|
+
}
|
|
47
|
+
|
|
23
48
|
module.exports = cds.service.impl(async function () {
|
|
24
49
|
this.after(['INSERT', 'UPSERT', 'UPDATE'], async (res, req) => {
|
|
25
|
-
if (!
|
|
26
|
-
|
|
27
|
-
for (const each in req.target.elements) {
|
|
28
|
-
const element = req.target.elements[each]
|
|
29
|
-
if (element['@assert']) {
|
|
30
|
-
has_asserts = true
|
|
31
|
-
break
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
req.target[$has_asserts] = has_asserts
|
|
35
|
-
}
|
|
50
|
+
if (!req.target) return
|
|
51
|
+
if (!($has_asserts in req.target)) _hasAssert(req.target)
|
|
36
52
|
|
|
37
53
|
if (!cds.context?.tx || !req.target[$has_asserts]) return
|
|
38
54
|
|
|
@@ -70,7 +86,7 @@ module.exports = cds.service.impl(async function () {
|
|
|
70
86
|
const asserts = []
|
|
71
87
|
|
|
72
88
|
for (const element of Object.values(entity.elements)) {
|
|
73
|
-
if (element._foreignKey4) continue
|
|
89
|
+
// if (element._foreignKey4) continue
|
|
74
90
|
if (element.isAssociation && !element.isComposition) continue
|
|
75
91
|
|
|
76
92
|
const assert = element['@assert']
|