@cap-js/db-service 1.9.0 → 1.9.1

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
+ ## [1.9.1](https://github.com/cap-js/cds-dbs/compare/db-service-v1.9.0...db-service-v1.9.1) (2024-05-16)
8
+
9
+
10
+ ### Fixed
11
+
12
+ * dont mistake non-key access with foreign key ([#642](https://github.com/cap-js/cds-dbs/issues/642)) ([2cd2349](https://github.com/cap-js/cds-dbs/commit/2cd234994d6a9e99765e56f7548a42a35279a790))
13
+
7
14
  ## [1.9.0](https://github.com/cap-js/cds-dbs/compare/db-service-v1.8.0...db-service-v1.9.0) (2024-05-08)
8
15
 
9
16
 
package/lib/SQLService.js CHANGED
@@ -1,4 +1,4 @@
1
- const cds = require('@sap/cds/lib'),
1
+ const cds = require('@sap/cds'),
2
2
  DEBUG = cds.debug('sql|db')
3
3
  const { Readable } = require('stream')
4
4
  const { resolveView } = require('@sap/cds/libx/_runtime/common/utils/resolveView')
@@ -135,7 +135,7 @@ class SQLService extends DatabaseService {
135
135
  if (query._streaming) {
136
136
  this._changeToStreams(cqn.SELECT.columns, rows, true, true)
137
137
  if (!rows.length) return
138
-
138
+
139
139
  const result = rows[0]
140
140
  // stream is always on position 0. Further properties like etag are inserted later.
141
141
  let [key, val] = Object.entries(result)[0]
@@ -1,7 +1,7 @@
1
1
  const SessionContext = require('./session-context')
2
2
  const ConnectionPool = require('./generic-pool')
3
3
  const infer = require('../infer')
4
- const cds = require('@sap/cds/lib')
4
+ const cds = require('@sap/cds')
5
5
 
6
6
  /** @typedef {unknown} DatabaseDriver */
7
7
 
@@ -1,4 +1,4 @@
1
- const cds = require('@sap/cds/lib')
1
+ const cds = require('@sap/cds')
2
2
 
3
3
  class SessionContext {
4
4
  constructor(ctx) {
package/lib/cqn2sql.js CHANGED
@@ -1,4 +1,4 @@
1
- const cds = require('@sap/cds/lib')
1
+ const cds = require('@sap/cds')
2
2
  const cds_infer = require('./infer')
3
3
  const cqn4sql = require('./cqn4sql')
4
4
 
package/lib/cqn4sql.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const cds = require('@sap/cds/lib')
3
+ const cds = require('@sap/cds')
4
4
  const { computeColumnsToBeSearched } = require('./search')
5
5
 
6
6
  const infer = require('./infer')
@@ -2175,10 +2175,10 @@ module.exports = Object.assign(cqn4sql, {
2175
2175
  function calculateElementName(token) {
2176
2176
  const nonJoinRelevantAssoc = [...token.$refLinks].findIndex(l => l.definition.isAssociation && l.onlyForeignKeyAccess)
2177
2177
  let name
2178
- if (nonJoinRelevantAssoc)
2178
+ if (nonJoinRelevantAssoc !== -1)
2179
2179
  // calculate fk name
2180
2180
  name = token.ref.slice(nonJoinRelevantAssoc).join('_')
2181
- else name = token.$refLinks[token.$refLinks.length - 1].definition.name
2181
+ else name = getFullName(token.$refLinks[token.$refLinks.length - 1].definition)
2182
2182
  return name
2183
2183
  }
2184
2184
 
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const cds = require('@sap/cds/lib')
3
+ const cds = require('@sap/cds')
4
4
 
5
5
  const JoinTree = require('./join-tree')
6
6
  const { pseudos } = require('./pseudos')
@@ -199,7 +199,7 @@ class JoinTree {
199
199
  }
200
200
  const child = new Node($refLink, node, where, args)
201
201
  if (child.$refLink.definition.isAssociation) {
202
- if (child.where || col.inline) {
202
+ if (child.where || child.$refLink.definition.on || col.inline) {
203
203
  // filter is always join relevant
204
204
  // if the column ends up in an `inline` -> each assoc step is join relevant
205
205
  child.$refLink.onlyForeignKeyAccess = false
@@ -212,9 +212,11 @@ class JoinTree {
212
212
  const elements =
213
213
  node.$refLink?.definition.isAssociation &&
214
214
  (node.$refLink.definition.elements || node.$refLink.definition.foreignKeys)
215
- if (node.$refLink && (!elements || !(child.$refLink.definition.name in elements)))
216
- // foreign key access
215
+ if (node.$refLink && (!elements || !(child.$refLink.definition.name in elements))) {
216
+ // no foreign key access
217
217
  node.$refLink.onlyForeignKeyAccess = false
218
+ col.$refLinks[i - 1] = node.$refLink
219
+ }
218
220
 
219
221
  node.children.set(id, child)
220
222
  node = child
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/db-service",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
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": {