@sap/cds 5.9.6 → 5.9.7

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 CHANGED
@@ -4,6 +4,12 @@
4
4
  - The format is based on [Keep a Changelog](http://keepachangelog.com/).
5
5
  - This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## Version 5.9.7 - 2022-06-13
8
+
9
+ ### Fixed
10
+
11
+ - Deleting a parent will delete all compositions, also texts
12
+ - Views with aliased elements in `orderBy`
7
13
 
8
14
  ## Version 5.9.6 - 2022-05-24
9
15
 
@@ -135,20 +135,17 @@ function _getStaticWhere(allBackLinks, entity1) {
135
135
  }, [])
136
136
  }
137
137
 
138
- const _is2oneComposition = (element, model) => {
139
- const csnElement = element.target && model.definitions[element.target].elements[element.name]
140
- return csnElement && csnElement.is2one && csnElement._isCompositionEffective
141
- }
142
-
143
138
  const _addToCQNs = (cqns, subCQN, element, model, level) => {
139
+ // REVISIT:
140
+ // The compiler generates foreign-key constraints (except if !cds.env.features._db_foreign_key_constraints)
141
+ // and enables DELETE CASCADE. For these cases, the runtime doesn't need to delete compositions
142
+ // manually, it's done by the database itself.
143
+ // However, there are cases (unmanaged compositions), where this doesn't happen.
144
+ // As a first step, the runtime will delete _all_ compositions regardless of the database.
145
+ // In the future, the runtime can enable the deletion of only those compositions
146
+ // which wouldn't be deleted by the database.
144
147
  cqns[level] = cqns[level] || []
145
- // Since `>2.5.2` compiler generates constraints for compositions of one like for annotations
146
- // Thus only single 2one case (`$self`-managed composition) has DELETE CASCADE
147
- // Here it's ignored to simplify i.e. handle all "2ones" in a same manner
148
- // REVISIT: why is _db_foreign_key_constraints necessary?
149
- if (!cds.env.features._db_foreign_key_constraints || _is2oneComposition(element, model)) {
150
- cqns[level].push(subCQN)
151
- }
148
+ cqns[level].push(subCQN)
152
149
  }
153
150
 
154
151
  // unofficial config!
@@ -27,7 +27,10 @@ const _getStaticOrders = req => {
27
27
 
28
28
  if (entity.query && entity.query.SELECT && entity.query.SELECT.orderBy) {
29
29
  const orderBy = entity.query.SELECT.orderBy
30
- const ordersFromView = orderBy.map(keyName => ({ by: { '=': keyName.ref[0] }, desc: keyName.sort === 'desc' }))
30
+ const ordersFromView = orderBy.map(keyName => ({
31
+ by: { '=': keyName.ref[keyName.ref.length - 1] },
32
+ desc: keyName.sort === 'desc'
33
+ }))
31
34
  return [...ordersFromView, ...defaultOrders, ...ordersFromKeys]
32
35
  }
33
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "5.9.6",
3
+ "version": "5.9.7",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [