@sap/cds 5.8.0 → 5.8.3

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 (42) hide show
  1. package/CHANGELOG.md +61 -4
  2. package/app/fiori/routes.js +3 -0
  3. package/bin/cds.js +7 -3
  4. package/bin/serve.js +2 -2
  5. package/lib/deploy.js +1 -1
  6. package/lib/log/format/kibana.js +3 -3
  7. package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +1 -3
  8. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/action.js +13 -0
  9. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ResourcePathParser.js +23 -2
  10. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriHelper.js +1 -1
  11. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ResourceJsonDeserializer.js +5 -6
  12. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ContextURLFactory.js +1 -1
  13. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ErrorJsonSerializer.js +2 -0
  14. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/UriHelper.js +4 -1
  15. package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +40 -5
  16. package/libx/_runtime/common/composition/index.js +1 -2
  17. package/libx/_runtime/common/composition/insert.js +3 -16
  18. package/libx/_runtime/common/composition/tree.js +1 -1
  19. package/libx/_runtime/common/error/frontend.js +2 -3
  20. package/libx/_runtime/common/i18n/index.js +2 -31
  21. package/libx/_runtime/common/utils/csn.js +15 -3
  22. package/libx/_runtime/common/utils/foreignKeyPropagations.js +9 -6
  23. package/libx/_runtime/common/utils/generateOnCond.js +5 -5
  24. package/libx/_runtime/common/utils/structured.js +10 -4
  25. package/libx/_runtime/db/expand/expandCQNToJoin.js +59 -20
  26. package/libx/_runtime/db/query/insert.js +1 -2
  27. package/libx/_runtime/db/sql-builder/SelectBuilder.js +7 -3
  28. package/libx/_runtime/db/utils/deep.js +10 -6
  29. package/libx/_runtime/fiori/generic/read.js +1 -3
  30. package/libx/_runtime/fiori/utils/handler.js +1 -11
  31. package/libx/_runtime/hana/conversion.js +2 -1
  32. package/libx/_runtime/hana/customBuilder/CustomSelectBuilder.js +1 -1
  33. package/libx/_runtime/hana/dynatrace.js +11 -5
  34. package/libx/_runtime/hana/execute.js +105 -8
  35. package/libx/_runtime/hana/search2cqn4sql.js +1 -4
  36. package/libx/_runtime/remote/utils/client.js +13 -4
  37. package/libx/_runtime/remote/utils/data.js +2 -1
  38. package/libx/gql/resolvers/crud/create.js +6 -1
  39. package/libx/gql/resolvers/crud/delete.js +6 -1
  40. package/libx/gql/resolvers/crud/read.js +6 -1
  41. package/libx/gql/resolvers/crud/update.js +11 -5
  42. package/package.json +1 -1
@@ -1,3 +1,5 @@
1
+ const cds = require('../../../../lib')
2
+
1
3
  const { ARGUMENT } = require('../../constants/adapter')
2
4
  const { getArgumentByName, astToColumns, astToWhere, astToEntries } = require('../parse/ast2cqn')
3
5
  const { entriesStructureToEntityStructure } = require('./utils')
@@ -5,16 +7,14 @@ const { entriesStructureToEntityStructure } = require('./utils')
5
7
  module.exports = async (service, entityFQN, selection) => {
6
8
  const filter = getArgumentByName(selection.arguments, ARGUMENT.FILTER)
7
9
 
8
- let queryBeforeUpdate = service.read(entityFQN)
10
+ const queryBeforeUpdate = service.read(entityFQN)
9
11
  queryBeforeUpdate.columns(astToColumns(selection.selectionSet.selections))
10
12
 
11
13
  if (filter) {
12
14
  queryBeforeUpdate.where(astToWhere(filter))
13
15
  }
14
16
 
15
- const resultBeforeUpdate = await service.tx(tx => tx.run(queryBeforeUpdate))
16
-
17
- let query = service.update(entityFQN)
17
+ const query = service.update(entityFQN)
18
18
 
19
19
  if (filter) {
20
20
  query.where(astToWhere(filter))
@@ -24,7 +24,13 @@ module.exports = async (service, entityFQN, selection) => {
24
24
  const entries = entriesStructureToEntityStructure(service, entityFQN, astToEntries(input))
25
25
  query.with(entries)
26
26
 
27
- const result = await service.tx(tx => tx.run(query))
27
+ let resultBeforeUpdate
28
+ const result = await service.tx(async tx => {
29
+ cds.context = tx
30
+ // read needs to be done before the update, otherwise the where clause might become invalid (case that properties in where clause are updated by the mutation)
31
+ resultBeforeUpdate = await tx.run(queryBeforeUpdate)
32
+ return tx.run(query)
33
+ })
28
34
 
29
35
  // Merge selected fields with updated data
30
36
  return resultBeforeUpdate.map(original => ({ ...original, ...result }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "5.8.0",
3
+ "version": "5.8.3",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [