@cap-js/db-service 1.15.0 → 1.15.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,14 @@
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.15.1](https://github.com/cap-js/cds-dbs/compare/db-service-v1.15.0...db-service-v1.15.1) (2024-11-18)
8
+
9
+
10
+ ### Fixed
11
+
12
+ * cross joins without on-condition ([#899](https://github.com/cap-js/cds-dbs/issues/899)) ([c61a04a](https://github.com/cap-js/cds-dbs/commit/c61a04aa4394511100f97cfebd362a2298221d96))
13
+ * pseudo paths in expands ([#896](https://github.com/cap-js/cds-dbs/issues/896)) ([014c50c](https://github.com/cap-js/cds-dbs/commit/014c50cec9c2de1ee3dfdf1861940ae0e2520c16))
14
+
7
15
  ## [1.15.0](https://github.com/cap-js/cds-dbs/compare/db-service-v1.14.1...db-service-v1.15.0) (2024-11-14)
8
16
 
9
17
 
package/lib/cqn2sql.js CHANGED
@@ -363,8 +363,7 @@ class CQN2SQLRenderer {
363
363
  return _aliased(this.quote(this.name(z)))
364
364
  }
365
365
  if (from.SELECT) return _aliased(`(${this.SELECT(from)})`)
366
- if (from.join)
367
- return `${this.from(from.args[0])} ${from.join} JOIN ${this.from(from.args[1])} ON ${this.where(from.on)}`
366
+ if (from.join) return `${this.from(from.args[0])} ${from.join} JOIN ${this.from(from.args[1])}${from.on ? ` ON ${this.where(from.on)}` : ''}`
368
367
  }
369
368
 
370
369
  /**
package/lib/cqn4sql.js CHANGED
@@ -1868,13 +1868,18 @@ function cqn4sql(originalQuery, model) {
1868
1868
  value: [],
1869
1869
  writable: true,
1870
1870
  })
1871
+ let pseudoPath = false
1871
1872
  ref.reduce((prev, res, i) => {
1872
1873
  if (res === '$self')
1873
1874
  // next is resolvable in entity
1874
1875
  return prev
1875
1876
  if (res in pseudos.elements) {
1877
+ pseudoPath = true
1876
1878
  thing.$refLinks.push({ definition: pseudos.elements[res], target: pseudos })
1877
1879
  return pseudos.elements[res]
1880
+ } else if (pseudoPath) {
1881
+ thing.$refLinks.push({ definition: {}, target: pseudos })
1882
+ return prev?.elements[res]
1878
1883
  }
1879
1884
  const definition =
1880
1885
  prev?.elements?.[res] || getDefinition(prev?.target)?.elements[res] || pseudos.elements[res]
@@ -172,12 +172,17 @@ function infer(originalQuery, model) {
172
172
  if (!ref) return
173
173
  init$refLinks(arg)
174
174
  let i = 0
175
+ let pseudoPath = false
175
176
  for (const step of ref) {
176
177
  const id = step.id || step
177
178
  if (i === 0) {
178
- // infix filter never have table alias
179
- // we need to search for first step in ´model.definitions[infixAlias]`
180
- if ($baseLink) {
179
+ if (id in pseudos.elements) {
180
+ // pseudo path
181
+ arg.$refLinks.push({ definition: pseudos.elements[id], target: pseudos })
182
+ pseudoPath = true // only first path step must be well defined
183
+ } else if ($baseLink) {
184
+ // infix filter never have table alias
185
+ // we need to search for first step in ´model.definitions[infixAlias]`
181
186
  const { definition } = $baseLink
182
187
  const elements = getDefinition(definition.target)?.elements || definition.elements
183
188
  const e = elements?.[id] || cds.error`"${id}" not found in the elements of "${definition.name}"`
@@ -201,11 +206,15 @@ function infer(originalQuery, model) {
201
206
  const definition = getDefinition(id) || cds.error`"${id}" not found in the definitions of your model`
202
207
  arg.$refLinks[0] = { definition, target: definition }
203
208
  }
209
+ } else if (arg.ref[0] === '$user' && pseudoPath) {
210
+ // `$user.some.unknown.element` -> no error
211
+ arg.$refLinks.push({ definition: {}, target: pseudos })
204
212
  } else {
205
213
  const recent = arg.$refLinks[i - 1]
206
214
  const { elements } = getDefinition(recent.definition.target) || recent.definition
207
215
  const e = elements[id]
208
- if (!e) throw new Error(`"${id}" not found in the elements of "${arg.$refLinks[i - 1].definition.name}"`)
216
+ const notFoundIn = pseudoPath ? arg.ref[i - 1] : getFullPathForLinkedArg(arg)
217
+ if (!e) throw new Error(`"${id}" not found in the elements of "${notFoundIn}"`)
209
218
  arg.$refLinks.push({ definition: e, target: getDefinition(e.target) || e })
210
219
  }
211
220
  arg.$refLinks[i].alias = !ref[i + 1] && arg.as ? arg.as : id.split('.').pop()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/db-service",
3
- "version": "1.15.0",
3
+ "version": "1.15.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": {