@sap/cds-compiler 4.4.2 → 4.4.4

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,12 @@
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
+ ## Version 4.4.4 - 2023-11-24
11
+
12
+ ### Fixed
13
+
14
+ - to.hdi.migration: Changes in only `doc`-comments should not result in a drop-create of the primary key.
15
+
10
16
  ## Version 4.4.2 - 2023-11-17
11
17
 
12
18
  ### Fixed
@@ -190,7 +190,7 @@ function getExtensionAndMigrations(beforeModel, options, { extensions, migration
190
190
  migration.change = changedElements;
191
191
  if(!hasPrimaryKeyChange)
192
192
  forEach(changedElements, (_name, change) => {
193
- if((change.old.key || change.new.key) && !change.new.target && !change.old.target) {
193
+ if(!change.onlyDoc && (change.old.key || change.new.key) && !change.new.target && !change.old.target) {
194
194
  // For to.hdi.migration: Just drop-create (commented out), for to.sql.migration: Handle case where we add/remove "key" keyword, no drop-create otherwise
195
195
  if(options.sqlDialect === 'hana' && options.src === 'hdi' || (!change.old.key || !change.new.key)) {
196
196
  hasPrimaryKeyChange = true;
@@ -276,6 +276,8 @@ function getElementComparator(otherArtifact, addedElementsDict = null, changedEl
276
276
  element.$notNull = false; // Explicitly set notNull to the implicit default so we render the correct ALTER
277
277
  }
278
278
  changedElementsDict[name] = changedElement(element, otherElement);
279
+ } else if(docCommentChanged(element, otherElement)) {
280
+ changedElementsDict[name] = { ...changedElement(element, otherElement), onlyDoc: true };
279
281
  }
280
282
 
281
283
  return;
@@ -356,6 +358,9 @@ function deepEqual(a, b, include = () => true, depth = 0) {
356
358
  : a === b;
357
359
  }
358
360
 
361
+ function docCommentChanged(element, otherElement) {
362
+ return element.doc && !otherElement.doc || otherElement.doc && !element.doc || element.doc && element.doc !== otherElement.doc;
363
+ }
359
364
 
360
365
  const relevantProperties = {
361
366
  'doc': true,
@@ -364,7 +369,8 @@ const relevantProperties = {
364
369
  };
365
370
 
366
371
  /**
367
- * Returns whether any type parameters differ between two given elements. Ignores whether types themselves differ (`type` property).
372
+ * Returns whether any type parameters differ between two given elements. Ignores whether types themselves differ (`type` property) and ignores
373
+ * diff in doc comments.
368
374
  * @param element {object} an element
369
375
  * @param otherElement {object} another element
370
376
  * @returns {boolean}
@@ -373,7 +379,7 @@ function typeParametersChanged(element, otherElement) {
373
379
  const checked = new Set();
374
380
  for (const key in element) {
375
381
  if (Object.prototype.hasOwnProperty.call(element, key))
376
- if((!key.startsWith('@') || relevantProperties[key]) && key !== 'type') {
382
+ if((!key.startsWith('@') || relevantProperties[key]) && key !== 'type' && key !== 'doc') {
377
383
  checked.add(key);
378
384
  if(!deepEqual(element[key], otherElement[key]))
379
385
  return true;
@@ -382,7 +388,7 @@ function typeParametersChanged(element, otherElement) {
382
388
 
383
389
  for (const key in otherElement) {
384
390
  if (Object.prototype.hasOwnProperty.call(otherElement, key))
385
- if((!key.startsWith('@') || relevantProperties[key]) && key !== 'type' && !checked.has(key))
391
+ if((!key.startsWith('@') || relevantProperties[key]) && key !== 'type' && key !== 'doc' && !checked.has(key))
386
392
  return true;
387
393
  }
388
394
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds-compiler",
3
- "version": "4.4.2",
3
+ "version": "4.4.4",
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)",