@sap/cds 5.9.2 → 5.9.5

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/lib/compile/for/drafts.js +1 -1
  3. package/lib/index.js +1 -1
  4. package/lib/serve/Service-methods.js +47 -1
  5. package/libx/_runtime/auth/index.js +16 -1
  6. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/BatchRequestListBuilder.js +3 -1
  7. package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +1 -3
  8. package/libx/_runtime/common/aspects/utils.js +8 -2
  9. package/libx/_runtime/common/composition/data.js +22 -13
  10. package/libx/_runtime/common/composition/delete.js +14 -12
  11. package/libx/_runtime/common/generic/auth/expand.js +1 -0
  12. package/libx/_runtime/common/generic/input.js +1 -0
  13. package/libx/_runtime/common/generic/put.js +1 -0
  14. package/libx/_runtime/common/utils/cqn.js +5 -10
  15. package/libx/_runtime/common/utils/cqn2cqn4sql.js +39 -75
  16. package/libx/_runtime/common/utils/foreignKeyPropagations.js +28 -8
  17. package/libx/_runtime/common/utils/path.js +3 -3
  18. package/libx/_runtime/common/utils/require.js +2 -1
  19. package/libx/_runtime/common/utils/resolveView.js +3 -0
  20. package/libx/_runtime/common/utils/structured.js +6 -1
  21. package/libx/_runtime/db/Service.js +10 -0
  22. package/libx/_runtime/db/expand/expand-v2.js +13 -5
  23. package/libx/_runtime/db/expand/expandCQNToJoin.js +56 -26
  24. package/libx/_runtime/db/utils/generateAliases.js +9 -0
  25. package/libx/_runtime/extensibility/uiflex/handler/transformWRITE.js +1 -0
  26. package/libx/_runtime/fiori/generic/read.js +83 -31
  27. package/libx/_runtime/fiori/generic/readOverDraft.js +22 -13
  28. package/libx/_runtime/fiori/utils/handler.js +3 -0
  29. package/libx/_runtime/fiori/utils/where.js +38 -25
  30. package/libx/_runtime/hana/driver.js +1 -1
  31. package/libx/_runtime/hana/search2cqn4sql.js +4 -1
  32. package/libx/_runtime/remote/Service.js +3 -3
  33. package/libx/_runtime/sqlite/convertAssocToOneManaged.js +19 -12
  34. package/package.json +1 -1
@@ -41,7 +41,7 @@ const _buildPartialUrlFunctions = (url, data, params, kind = 'odata-v4') => {
41
41
  const funcParams = []
42
42
  const queryOptions = []
43
43
  // REVISIT: take params from params after importer fix (the keys should not be part of params)
44
- for (const param in data) {
44
+ for (const param in _extractParamsFromData(data, params)) {
45
45
  if (kind === 'odata-v2') {
46
46
  funcParams.push(`${param}=${_setCorrectValue(param, data, params, kind)}`)
47
47
  } else {
@@ -54,7 +54,7 @@ const _buildPartialUrlFunctions = (url, data, params, kind = 'odata-v4') => {
54
54
  : `${url}(${funcParams.join(',')})?${queryOptions.join('&')}`
55
55
  }
56
56
 
57
- const _extractParamsFromData = (data, params) => {
57
+ const _extractParamsFromData = (data, params = {}) => {
58
58
  return Object.keys(data).reduce((res, el) => {
59
59
  if (params[el]) Object.assign(res, { [el]: data[el] })
60
60
  return res
@@ -118,7 +118,7 @@ const _handleV2BoundActionFunction = (srv, def, req, event, kind) => {
118
118
  const params = []
119
119
  const data = req.data
120
120
  // REVISIT: take params from def.params, after importer fix (the keys should not be part of params)
121
- for (const param in req.data) {
121
+ for (const param in _extractParamsFromData(req.data, def.params)) {
122
122
  params.push(`${param}=${formatVal(data[param], param, { elements: def.params }, kind)}`)
123
123
  }
124
124
  const keys = _buildKeys(req, this.kind)
@@ -17,29 +17,36 @@ const _getConvertibleEntries = req => {
17
17
  return [...orders, ...groups, ...filters, ...havings]
18
18
  }
19
19
 
20
- // REVISIT once sql can handle structured keys properly, this handler should not be required anymore
21
- const _handler = function (req) {
22
- // do simple checks upfront and exit early
23
- if (!req.query || typeof req.query === 'string') return
24
- if (!req.query.SELECT.orderBy && !req.query.SELECT.groupBy && !req.query.SELECT.where && !req.query.SELECT.having) {
25
- return
26
- }
27
-
28
- if (!req.target || !req.target.elements) return
20
+ const _convert = (refEntries, req) => {
21
+ for (const refEntry of refEntries) {
22
+ if (refEntry.xpr) {
23
+ _convert(refEntry.xpr, req)
24
+ continue
25
+ }
29
26
 
30
- for (const refEntry of _getConvertibleEntries(req)) {
31
27
  if (!refEntry.ref || refEntry.ref.length < 2) {
32
28
  // only check refs in format {ref: ['assoc', 'id']}
33
29
  continue
34
30
  }
35
-
36
31
  const element = req.target.elements[refEntry.ref[0]]
37
32
  if (!element || !element.is2one) return
38
-
39
33
  _convertRefForAssocToOneManaged(element, refEntry)
40
34
  }
41
35
  }
42
36
 
37
+ // REVISIT once sql can handle structured keys properly, this handler should not be required anymore
38
+ const _handler = function (req) {
39
+ // do simple checks upfront and exit early
40
+ if (!(req.query && req.query.SELECT) || typeof req.query === 'string') return
41
+ if (!req.query.SELECT.orderBy && !req.query.SELECT.groupBy && !req.query.SELECT.where && !req.query.SELECT.having) {
42
+ return
43
+ }
44
+
45
+ if (!req.target || !req.target.elements) return
46
+
47
+ _convert(_getConvertibleEntries(req), req)
48
+ }
49
+
43
50
  _handler._initial = true
44
51
 
45
52
  module.exports = _handler
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "5.9.2",
3
+ "version": "5.9.5",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [