@sap/cds 7.1.0 → 7.1.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
+ ## Version 7.1.1 - 2023-08-01
8
+
9
+ ### Fixed
10
+
11
+ - Lean draft: read actives via service on draft edit
12
+ - Resolve column name for `STREAM` CQN queries that point to views
13
+ - Only log the error in case of an unhandled rejection
14
+
7
15
  ## Version 7.1.0 - 2023-07-28
8
16
 
9
17
  ### Added
package/bin/serve.js CHANGED
@@ -206,8 +206,8 @@ async function serve (all=[], o={}) {
206
206
 
207
207
  const LOG = cds.log('cli|server')
208
208
  cds.shutdown = _shutdown //> for programmatic invocation
209
- process.on('unhandledRejection', (e,p) => _shutdown (e, LOG.error('❗️Uncaught',p)))
210
- process.on('uncaughtException', (e) => _shutdown (e, LOG.error('❗️Uncaught',e)))
209
+ process.on('unhandledRejection', e => _shutdown (e, cds.log('cds').error('❗️Uncaught',e)))
210
+ process.on('uncaughtException', e => _shutdown (e, cds.log('cds').error('❗️Uncaught',e)))
211
211
  process.on('SIGINT', cds.watched ? _shutdown : (s,n)=>_shutdown(s,n,console.log())) //> newline after ^C
212
212
  process.on('SIGHUP', _shutdown)
213
213
  process.on('SIGHUP2', _shutdown)
@@ -60,7 +60,7 @@ exports.impl = cds.service.impl(function () {
60
60
  }
61
61
 
62
62
  if (req.event === 'READ' && req.query?.SELECT) {
63
- req.query.SELECT.localized = true
63
+ req.query.SELECT.localized ??= true
64
64
  }
65
65
 
66
66
  if (!result) {
@@ -346,6 +346,8 @@ const _getWhereExistsSubSelect = (queryTarget, outerAlias, innerAlias, ref, mode
346
346
  if (condition.length > 1 || (condition.length === 1 && !('val' in condition[0]))) subSelect.where(condition)
347
347
  }
348
348
 
349
+ if (options.localized != null) subSelect.SELECT.localized = options.localized
350
+
349
351
  subSelect.where(queryTarget._relations[navName].join(innerAlias, outerAlias))
350
352
  if (cds.env.effective.odata.structs || cds.env.features.ucsn_struct_conversion) {
351
353
  flattenStructuredSelect(subSelect, model)
@@ -354,6 +356,7 @@ const _getWhereExistsSubSelect = (queryTarget, outerAlias, innerAlias, ref, mode
354
356
 
355
357
  // nested where exists needs recursive conversion
356
358
  options.lambdaIteration++
359
+
357
360
  return _convertSelect(subSelect, model, options)
358
361
  }
359
362
 
@@ -711,10 +714,11 @@ const _convertToOneEqNullInFilter = (query, target) => {
711
714
  }
712
715
  }
713
716
  }
717
+
714
718
  // eslint-disable-next-line complexity
715
719
  const _convertSelect = (query, model, _options) => {
716
720
  const _4db = _options.service?.isDatabaseService
717
- const options = Object.assign({ _4db, isStreaming: query._streaming }, _options)
721
+ const options = Object.assign({ _4db, isStreaming: query._streaming, localized: query.SELECT.localized }, _options)
718
722
 
719
723
  // ensure query is ql enabled
720
724
  if (!(query instanceof Query)) Object.setPrototypeOf(query, Object.getPrototypeOf(SELECT()))
@@ -419,7 +419,7 @@ const _newStream = (query, transitions) => {
419
419
  } else {
420
420
  newStream.into = targetName
421
421
  }
422
- if (newStream.column) newStream.column = _resolveColumn([newStream.column], targetTransition)
422
+ if (newStream.column) newStream.column = _resolveColumn(newStream.column, targetTransition)
423
423
  Object.defineProperty(newStream, '_transitions', {
424
424
  enumerable: false,
425
425
  value: transitions
@@ -11,7 +11,7 @@ const _redirectXpr = (xpr, localize) => {
11
11
  }
12
12
 
13
13
  if (ele.SELECT) {
14
- if (!ele._suppressLocalization) redirect(ele.SELECT, localize)
14
+ if (ele.SELECT.localized) redirect(ele.SELECT, localize)
15
15
  }
16
16
  })
17
17
  }
@@ -115,7 +115,7 @@ const fioriGenericEdit = async function (req, next) {
115
115
  for (const q of selectCQNs) {
116
116
  const entity = definitions[q.SELECT.from.ref[0]]
117
117
  if (entity && !entity.name.match(/\.texts$/)) {
118
- Object.defineProperty(q, '_suppressLocalization', { value: true })
118
+ q.SELECT.localized = false
119
119
  }
120
120
  }
121
121
 
@@ -967,7 +967,7 @@ async function onEdit(req) {
967
967
  existingDraft[DRAFT_PARAMS] = draftParams
968
968
 
969
969
  const activeCQN = SELECT.one.from(req.target).columns(cols).where(targetWhere)
970
- activeCQN._suppressLocalization = true // in the future we should be able to just set activeCQN.SELECT.localized = false
970
+ activeCQN.SELECT.localized = false
971
971
 
972
972
  const activeCheck = SELECT.one(req.target).columns([1]).where(targetWhere).forUpdate()
973
973
  activeCheck[DRAFT_PARAMS] = draftParams
@@ -979,7 +979,8 @@ async function onEdit(req) {
979
979
  } catch {} // eslint-disable-line no-empty
980
980
 
981
981
  const [res, draft] = await _promiseAll([
982
- this._datasource.run(activeCQN),
982
+ // REVISIT: inofficial compat flag just in case it breaks something -> do not document
983
+ cds.env.fiori.read_actives_from_db ? this._datasource.run(activeCQN) : this.run(activeCQN),
983
984
  // no user check must be done here...
984
985
  existingDraft
985
986
  ])
@@ -21,7 +21,7 @@ const localizedHandler = function (req) {
21
21
  if (!req.locale) return
22
22
 
23
23
  // suppress localization by instruction
24
- if (query._suppressLocalization) return
24
+ if (query.SELECT.localized === false) return
25
25
 
26
26
  // suppress localization for pure counts
27
27
  const columns = query.SELECT.columns
@@ -60,8 +60,10 @@ const search2cqn4sql = (query, entity, options) => {
60
60
  subQuery.where(expression)
61
61
 
62
62
  // suppress the localize handler from redirecting the subQuery's target to the localized view
63
- Object.defineProperty(subQuery, '_suppressLocalization', { value: true })
63
+ subQuery.SELECT.localized = false
64
+
64
65
  query.where('exists', subQuery)
66
+
65
67
  return query
66
68
  }
67
69
 
@@ -33,7 +33,7 @@ const sqliteLocalized = function (req) {
33
33
  if (!req.locale) return
34
34
 
35
35
  // suppress localization by instruction
36
- if (query._suppressLocalization) return
36
+ if (query.SELECT.localized === false) return
37
37
 
38
38
  // suppress localization for pure counts
39
39
  const columns = query.SELECT.columns
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "7.1.0",
3
+ "version": "7.1.1",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [