@cap-js/db-service 2.1.1 → 2.1.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 CHANGED
@@ -4,6 +4,13 @@
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
+ ## [2.1.2](https://github.com/cap-js/cds-dbs/compare/db-service-v2.1.1...db-service-v2.1.2) (2025-06-12)
8
+
9
+
10
+ ### Fixed
11
+
12
+ * Hierarchy View support for ancestors/descendants requests ([#1241](https://github.com/cap-js/cds-dbs/issues/1241)) ([1ccb8b7](https://github.com/cap-js/cds-dbs/commit/1ccb8b7ded50f77de1d71d79b0c4b2040ee6a4f1))
13
+
7
14
  ## [2.1.1](https://github.com/cap-js/cds-dbs/compare/db-service-v2.1.0...db-service-v2.1.1) (2025-06-06)
8
15
 
9
16
 
package/lib/cqn2sql.js CHANGED
@@ -376,11 +376,12 @@ class CQN2SQLRenderer {
376
376
  const expandedByOne = { list: [] } // DistanceTo(...,1)
377
377
  const expandedByZero = { list: [] } // not DistanceTo(...,null)
378
378
  let expandedFilter = []
379
+ // If a root where exists it should always be DistanceFromRoot otherwise when a recurse.where exists with only DistanceTo() calls
379
380
  let distanceType = 'DistanceFromRoot'
380
381
  let distanceVal
381
382
 
382
383
  if (recurse.where) {
383
- distanceType = 'Distance'
384
+ distanceType = where?.length ? 'DistanceFromRoot' : 'Distance'
384
385
  if (recurse.where[0] === 'and') recurse.where = recurse.where.slice(1)
385
386
  expandedFilter = [...recurse.where]
386
387
  collectDistanceTo(expandedFilter)
@@ -463,7 +464,7 @@ class CQN2SQLRenderer {
463
464
  },
464
465
  where: expandedFilter.length ? expandedFilter : undefined,
465
466
  orderBy: [{ ref: ['HIERARCHY_RANK'], sort: 'asc' }],
466
- groupBy: [{ ref: ['NODE_ID'] },{ ref: ['PARENT_ID'] }, { ref: ['HIERARCHY_RANK'] }, { ref: ['HIERARCHY_LEVEL'] }, { ref: ['HIERARCHY_TREE_SIZE'] }, ...columnsOut.filter(c => c.ref)],
467
+ groupBy: [{ ref: ['NODE_ID'] }, { ref: ['PARENT_ID'] }, { ref: ['HIERARCHY_RANK'] }, { ref: ['HIERARCHY_LEVEL'] }, { ref: ['HIERARCHY_TREE_SIZE'] }, ...columnsOut.filter(c => c.ref)],
467
468
  }
468
469
  }
469
470
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/db-service",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "CDS base database service",
5
5
  "homepage": "https://github.com/cap-js/cds-dbs/tree/main/db-service#cds-base-database-service",
6
6
  "repository": {