@sap/cds-compiler 3.9.4 → 3.9.6

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
@@ -7,6 +7,15 @@
7
7
  Note: `beta` fixes, changes and features are usually not listed in this ChangeLog but [here](doc/CHANGELOG_BETA.md).
8
8
  The compiler behavior concerning `beta` features can change at any time without notice.
9
9
 
10
+
11
+ ## Version 3.9.6 - 2023-07-27
12
+
13
+ ### Fixed
14
+
15
+ - to.edm(x): Revert change introduced with [3.9.0](#version-390---2023-04-20)
16
+ "Correct referential constraint calculation for `[0..1]` backlink associations".
17
+ - for.odata: Process shortcut annotations sequence independent.
18
+
10
19
  ## Version 3.9.4 - 2023-06-07
11
20
 
12
21
  ### Fixed
package/lib/edm/edm.js CHANGED
@@ -1217,13 +1217,16 @@ function getEdm(options, messageFunctions) {
1217
1217
  // V4 referential constraints!
1218
1218
  addReferentialConstraintNodes()
1219
1219
  {
1220
+ // flip the constrains if this is a $self partner
1220
1221
  let _constraints = this._csn._constraints;
1222
+ let [i,j] = [0,1];
1221
1223
  if(this._csn._constraints._partnerCsn) {
1222
1224
  _constraints = this._csn._constraints._partnerCsn._constraints;
1225
+ [i,j] = [1,0];
1223
1226
  }
1224
1227
  _constraints.constraints && Object.values(_constraints.constraints).forEach(c =>
1225
1228
  this.append(new ReferentialConstraint(this._v,
1226
- { Property: c[0].join(options.pathDelimiter), ReferencedProperty: c[1].join(options.pathDelimiter) } ) )
1229
+ { Property: c[i].join(options.pathDelimiter), ReferencedProperty: c[j].join(options.pathDelimiter) } ) )
1227
1230
  );
1228
1231
  }
1229
1232
  }
@@ -413,6 +413,12 @@ function checkExtensionDict( dict ) {
413
413
  def[prop] = dup[prop]; // continuation semantics: last wins
414
414
  }
415
415
  }
416
+ if (dup.$annotations) { // update deprecated $annotations for cds-lsp / annotation modeler
417
+ if (def.$annotations)
418
+ def.$annotations.push( ...dup.$annotations );
419
+ else
420
+ def.$annotations = dup.$annotations;
421
+ }
416
422
  }
417
423
  def.$duplicates = null;
418
424
  }
@@ -346,44 +346,41 @@ function transform4odataWithCsn(inputModel, options) {
346
346
  setAnnotation(node, name.replace(setPrefix, setMappings[setPrefix]), node[name]);
347
347
  }
348
348
  }
349
-
349
+ });
350
350
  // Special case: '@readonly' becomes a triplet of capability restrictions for entities,
351
351
  // but '@Core.Immutable' for everything else.
352
- if (!(node['@readonly'] && node['@insertonly'])) {
353
- if (name === '@readonly' && node[name]) {
354
- if (node.kind === 'entity' || node.kind === 'aspect') {
355
- setAnnotation(node, '@Capabilities.DeleteRestrictions.Deletable', false);
356
- setAnnotation(node, '@Capabilities.InsertRestrictions.Insertable', false);
357
- setAnnotation(node, '@Capabilities.UpdateRestrictions.Updatable', false);
358
- } else {
359
- setAnnotation(node, '@Core.Computed', true);
360
- }
352
+ if (!(node['@readonly'] && node['@insertonly'])) {
353
+ if (node['@readonly']) {
354
+ if (node.kind === 'entity' || node.kind === 'aspect') {
355
+ setAnnotation(node, '@Capabilities.DeleteRestrictions.Deletable', false);
356
+ setAnnotation(node, '@Capabilities.InsertRestrictions.Insertable', false);
357
+ setAnnotation(node, '@Capabilities.UpdateRestrictions.Updatable', false);
358
+ } else {
359
+ setAnnotation(node, '@Core.Computed', true);
361
360
  }
361
+ }
362
362
  // @insertonly is effective on entities/queries only
363
- else if (name === '@insertonly' && node[name]) {
364
- if (node.kind === 'entity' || node.kind === 'aspect') {
365
- setAnnotation(node, '@Capabilities.DeleteRestrictions.Deletable', false);
366
- setAnnotation(node, '@Capabilities.ReadRestrictions.Readable', false);
367
- setAnnotation(node, '@Capabilities.UpdateRestrictions.Updatable', false);
368
- }
369
- }
363
+ if (node['@insertonly'] && (node.kind === 'entity' || node.kind === 'aspect')) {
364
+ setAnnotation(node, '@Capabilities.DeleteRestrictions.Deletable', false);
365
+ setAnnotation(node, '@Capabilities.ReadRestrictions.Readable', false);
366
+ setAnnotation(node, '@Capabilities.UpdateRestrictions.Updatable', false);
370
367
  }
368
+ }
371
369
  // Only on element level: translate @mandatory
372
- if (name === '@mandatory' && node[name] &&
370
+ if (node['@mandatory'] &&
373
371
  node.kind === undefined && node['@Common.FieldControl'] === undefined) {
374
- setAnnotation(node, '@Common.FieldControl', { '#': 'Mandatory' });
375
- }
372
+ setAnnotation(node, '@Common.FieldControl', { '#': 'Mandatory' });
373
+ }
376
374
 
377
- if (name === '@assert.format' && node[name] !== null)
378
- setAnnotation(node, '@Validation.Pattern', node['@assert.format']);
375
+ if (node['@assert.format'] != null)
376
+ setAnnotation(node, '@Validation.Pattern', node['@assert.format']);
379
377
 
380
- if (name === '@assert.range' && node[name] !== null) {
381
- if (Array.isArray(node['@assert.range']) && node['@assert.range'].length === 2) {
382
- setAnnotation(node, '@Validation.Minimum', node['@assert.range'][0]);
383
- setAnnotation(node, '@Validation.Maximum', node['@assert.range'][1]);
384
- }
378
+ if (node['@assert.range'] != null) {
379
+ if (Array.isArray(node['@assert.range']) && node['@assert.range'].length === 2) {
380
+ setAnnotation(node, '@Validation.Minimum', node['@assert.range'][0]);
381
+ setAnnotation(node, '@Validation.Maximum', node['@assert.range'][1]);
385
382
  }
386
- });
383
+ }
387
384
  }
388
385
 
389
386
  // Apply default type facets to each type definition and every member
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds-compiler",
3
- "version": "3.9.4",
3
+ "version": "3.9.6",
4
4
  "description": "CDS (Core Data Services) compiler and backends",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "author": "SAP SE (https://www.sap.com)",