Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sap/cds-compiler

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap/cds-compiler - npm Package Compare versions

Comparing version 1.50.8 to 1.50.10

6

CHANGELOG.md

@@ -10,2 +10,8 @@ # ChangeLog for cdx compiler and backends

## Version 1.50.10 - 2021-07-30
### Fixed
- to.hdi.migration: Check for incompatible CSN versions to avoid wrongly generated ALTER|DROP|ADD statements.
## Version 1.50.8 - 2021-07-01

@@ -12,0 +18,0 @@

10

lib/api/main.js

@@ -267,3 +267,3 @@ /** @module API */

// Compare both images.
const diff = compareModels(beforeImage || afterImage, afterImage);
const diff = compareModels(beforeImage || afterImage, afterImage, internalOptions);

@@ -713,2 +713,8 @@ // Convert the diff to SQL.

/**
* Available SQL change modes
*
* @typedef {'alter' | 'drop' } SqlChangeMode
*/
/**
* Available oData versions

@@ -749,2 +755,4 @@ *

* @property {SQLDialect} [sqlDialect='hana'] SQL dialect to use - hana, hanaJoins, hanaAssocs
* @property {SqlChangeMode} [sqlChangeMode='alter'] SQL change mode to use (for changed columns)
* @property {boolean} [allowCsnDowngrade=false] Allow downgrades of CSN major version (for modelCompare)
* @property {boolean} [beta=false] Enable experimental features - not for productive use!

@@ -751,0 +759,0 @@ * @property {boolean} [longAutoexposed=false] Deprecated: Produce long names (with underscores) for autoexposed entities

@@ -18,2 +18,3 @@ 'use strict';

'sqlChangeMode',
'allowCsnDowngrade',
'joinfk',

@@ -20,0 +21,0 @@ 'magicVars',

'use strict';
const { makeMessageFunction } = require('../base/messages');
const {

@@ -14,6 +15,10 @@ forEachDefinition,

* @param afterModel the after-model
* @param {hdiOptions|false} options
* @returns {object} the sets of deletions, extensions, and migrations of entities necessary to transform the before-model
* to the after-model, together with all the definitions of the after-model
*/
function compareModels(beforeModel, afterModel) {
function compareModels(beforeModel, afterModel, options) {
if(!(options && options.testMode)) // no $version with testMode
validateCsnVersions(beforeModel, afterModel, options);
const deletedEntities = Object.create(null);

@@ -35,2 +40,25 @@ const elementAdditions = [];

function validateCsnVersions(beforeModel, afterModel, options) {
const beforeVersion = beforeModel.$version;
const afterVersion = afterModel.$version;
let beforeVersionParts = beforeVersion && beforeVersion.split('.');
let afterVersionParts = afterVersion && afterVersion.split('.');
if (!beforeVersionParts || beforeVersionParts.length < 2) {
const { error, throwWithError } = makeMessageFunction(beforeModel, options, 'modelCompare');
error(null, null, `Invalid CSN version: ${beforeVersion}`);
throwWithError();
}
if (!afterVersionParts || afterVersionParts.length < 2) {
const { error, throwWithError } = makeMessageFunction(afterModel, options, 'modelCompare');
error(null, null, `Invalid CSN version: ${afterVersion}`);
throwWithError();
}
if (beforeVersionParts[0] > afterVersionParts[0] && !(options && options.allowCsnDowngrade)) {
const { error, throwWithError } = makeMessageFunction(afterModel, options, 'modelCompare');
error(null, null, `Incompatible CSN versions: ${afterVersion} is a major downgrade from ${beforeVersion}. Is @sap/cds-compiler version ${require('../../package.json').version} outdated?`);
throwWithError();
}
}
function getArtifactComparator(otherModel, addedEntities, deletedEntities, elementAdditions, elementChanges) { // (, alerts)

@@ -37,0 +65,0 @@ return function compareArtifacts(artifact, name) { // (, topKey, path) topKey == 'definitions'

2

package.json
{
"name": "@sap/cds-compiler",
"version": "1.50.8",
"version": "1.50.10",
"description": "CDS (Core Data Services) compiler and backends",

@@ -5,0 +5,0 @@ "homepage": "https://cap.cloud.sap/",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc