@sap/cds-compiler
Advanced tools
Comparing version 1.49.0 to 1.49.2
@@ -9,2 +9,13 @@ # ChangeLog for cdx compiler and backends | ||
## Version 1.49.2 - 2021-02-16 | ||
### Fixed | ||
- to.edm(x): Illegal OData identifiers which are not exposed in the generated edmx schema are not causing errors anymore. | ||
- to.cdl: Annotations are now rendered with the new delimited Identifier syntax | ||
- to.sql/hdi: | ||
+ Fixed a bug which led to an exception if elements were referenced as types. | ||
+ For the SQLite dialect, date, time and timestamp are rendered as simple string literals instead of function calls. | ||
+ For naming mode "plain", date, time and timestamps are rendered as SQL-compliant literals. | ||
## Version 1.49.0 - 2021-01-29 | ||
@@ -23,3 +34,3 @@ | ||
## Changed | ||
### Changed | ||
@@ -34,3 +45,3 @@ - OData/EDMX: | ||
## Fixed | ||
### Fixed | ||
@@ -37,0 +48,0 @@ - Structured foreign key and forward association reference paths used in ON condition definitions |
@@ -22,5 +22,5 @@ 'use strict'; | ||
* | ||
* @param {Object[]} on On-Condition | ||
* @param {Number} startIndex Index of the current expression to "look around" | ||
* @returns {boolean} | ||
* @param {Array} on On-Condition | ||
* @param {number} startIndex Index of the current expression to "look around" | ||
* @returns {boolean} True if valid | ||
*/ | ||
@@ -47,19 +47,18 @@ function otherSideIsValidDollarSelf(on, startIndex){ | ||
/* | ||
* Check that the opposite operand to a relational term is something | ||
* structured that can be used for tuple expansion. This can either be a | ||
* real 'elements' thing or a managed association/composition with foreign keys. | ||
* | ||
* @param {Object[]} on On-Condition | ||
* @param {Number} startIndex Index of the current expression to "look around" | ||
* @param {Object} this to obtain bound functions and model | ||
* @returns {boolean} | ||
*/ | ||
function otherSideIsExpandableStructure(on, startIndex, me) { | ||
if(on[startIndex-1] && ['=', '<', '>', '>=', '<=', '!=', '<>'].includes(on[startIndex-1])) { | ||
return isOk(resolveArtifactType(on[startIndex-2]._art, me)); | ||
} | ||
else if(on[startIndex+1] && ['=', '<', '>', '>=', '<=', '!=', '<>'].includes(on[startIndex+1])) { | ||
return isOk(resolveArtifactType(on[startIndex+2]._art, me)); | ||
} | ||
/** | ||
* Check that the opposite operand to a relational term is something | ||
* structured that can be used for tuple expansion. This can either be a | ||
* real 'elements' thing or a managed association/composition with foreign keys. | ||
* | ||
* @param {Array} on the on condition which to check | ||
* @param {number} startIndex the index of the relational term in the on condition array | ||
* @returns {boolean} indicates whether the other side of a relational term is expandable | ||
*/ | ||
function otherSideIsExpandableStructure(on, startIndex) { | ||
if (on[startIndex - 1] && [ '=', '<', '>', '>=', '<=', '!=', '<>' ].includes(on[startIndex - 1])) | ||
return isOk(resolveArtifactType.call(this, on[startIndex - 2]._art)); | ||
else if (on[startIndex + 1] && [ '=', '<', '>', '>=', '<=', '!=', '<>' ].includes(on[startIndex + 1])) | ||
return isOk(resolveArtifactType.call(this, on[startIndex + 2]._art)); | ||
return false; | ||
@@ -73,18 +72,12 @@ | ||
/* | ||
* @param {Object} artifact | ||
* @param {Object} this to obtain bound functions and model | ||
* @returns {Object} final artifact type | ||
/** | ||
* Get the real type of an artifact | ||
* | ||
* @param {object} art Whatever _art by csnRefs can be - element or artifact | ||
* @returns {object} final artifact type | ||
*/ | ||
function resolveArtifactType(art, me) { | ||
if(art && art.type) { | ||
// 1) Dereference 'type of' | ||
if(art.type.ref) { // type of | ||
art = me.artifactRef(art.type); | ||
} | ||
// 2) Lookup named 'type T', if not builtin | ||
if(art && art.type && !isBuiltinType(art.type)) { | ||
art = me.csn.definitions[me.effectiveType(art.type)]; | ||
} | ||
} | ||
function resolveArtifactType(art) { | ||
if (art && art.type && !isBuiltinType(art.type)) | ||
return this.getFinalBaseType(art); | ||
return art; | ||
@@ -115,5 +108,5 @@ } | ||
const validDollarSelf = otherSideIsValidDollarSelf(member.on, i); | ||
const validStructuredElement = otherSideIsExpandableStructure(member.on, i, this); | ||
for(let j = 0; j < _links.length-1; j++){ | ||
const csnPath = path.concat(['on', i, 'ref', j]); | ||
const validStructuredElement = otherSideIsExpandableStructure.call(this, member.on, i); | ||
for (let j = 0; j < _links.length - 1; j++) { | ||
const csnPath = path.concat([ 'on', i, 'ref', j ]); | ||
@@ -141,4 +134,4 @@ if(_links[j].art.target && !((_links[j].art === member) || ref[j] === '$self' || ref[j] === '$projection' || (validDollarSelf && j === _links.length - 1))){ | ||
} | ||
if(_art && $scope !== '$self') { | ||
_art = resolveArtifactType(_art, this); | ||
if (_art && $scope !== '$self') { | ||
_art = resolveArtifactType.call(this, _art); | ||
// Paths of an ON condition may end on a structured element or an association only if: | ||
@@ -145,0 +138,0 @@ // 1) Both operands in the expression end on a structured element or on |
@@ -36,32 +36,2 @@ 'use strict'; | ||
return function compareArtifacts(artifact, name) { // (, topKey, path) topKey == 'definitions' | ||
function addElements() { | ||
const elements = {}; | ||
forEachMember(artifact, getElementComparator(otherArtifact, elements)); | ||
if (Object.keys(elements).length > 0) { | ||
elementAdditions.push({ | ||
extend: name, | ||
elements: elements | ||
}); | ||
} | ||
} | ||
function removeOrChangeElements() { | ||
const removedElements = {}; | ||
const changedElements = {}; | ||
const modification = { migrate: name }; | ||
forEachMember(otherArtifact, getElementComparator(artifact, removedElements)); | ||
if (Object.keys(removedElements).length > 0) { | ||
modification.remove = removedElements; | ||
} | ||
forEachMember(artifact, getElementComparator(otherArtifact, null, changedElements)); | ||
if (Object.keys(changedElements).length > 0) { | ||
modification.change = changedElements; | ||
} | ||
if (modification.remove || modification.change) { | ||
elementChanges.push(modification); | ||
} | ||
} | ||
const otherArtifact = otherModel.definitions[name]; | ||
@@ -103,2 +73,33 @@ const isPersisted = isPersistedAsTable(artifact); | ||
} | ||
function addElements() { | ||
const elements = {}; | ||
forEachMember(artifact, getElementComparator(otherArtifact, elements)); | ||
if (Object.keys(elements).length > 0) { | ||
elementAdditions.push({ | ||
extend: name, | ||
elements: elements | ||
}); | ||
} | ||
} | ||
function removeOrChangeElements() { | ||
const removedElements = {}; | ||
const changedElements = {}; | ||
const modification = { migrate: name }; | ||
forEachMember(otherArtifact, getElementComparator(artifact, removedElements)); | ||
if (Object.keys(removedElements).length > 0) { | ||
modification.remove = removedElements; | ||
} | ||
forEachMember(artifact, getElementComparator(otherArtifact, null, changedElements)); | ||
if (Object.keys(changedElements).length > 0) { | ||
modification.change = changedElements; | ||
} | ||
if (modification.remove || modification.change) { | ||
elementChanges.push(modification); | ||
} | ||
} | ||
}; | ||
@@ -105,0 +106,0 @@ } |
@@ -1158,4 +1158,4 @@ | ||
if (options.toSql.dialect === 'sqlite') { | ||
// date('2017-11-02') | ||
return `${x.literal}('${x.val}')`; | ||
// simple string literal '2017-11-02' | ||
return `'${x.val}'`; | ||
} else { | ||
@@ -1162,0 +1162,0 @@ // date'2017-11-02' |
@@ -128,2 +128,3 @@ 'use strict'; | ||
effectiveType, | ||
getFinalBaseType, | ||
} = csnUtils; | ||
@@ -181,3 +182,3 @@ | ||
validator(csn, { | ||
error, warning, info, inspectRef, effectiveType, artifactRef, csn, | ||
error, warning, info, inspectRef, effectiveType, artifactRef, csn, getFinalBaseType, | ||
}, | ||
@@ -184,0 +185,0 @@ /* Member Validators */ [ validateOnCondition, validateForeignKeys, validateAssociationsInArrayOf, validateDefaultValues ], |
@@ -12,4 +12,3 @@ 'use strict'; | ||
// eslint-disable-next-line no-unused-vars | ||
const { copyAnnotations, printableName, hasBoolAnnotation, forEachDefinition } = require('../model/modelUtils'); | ||
const { copyAnnotations } = require('../model/modelUtils'); | ||
const { cloneCsn, forEachMemberRecursively, forEachGeneric, forAllQueries, | ||
@@ -16,0 +15,0 @@ forEachRef, getUtils, isBuiltinType } = require('../model/csnUtils'); |
{ | ||
"name": "@sap/cds-compiler", | ||
"version": "1.49.0", | ||
"version": "1.49.2", | ||
"description": "CDS (Core Data Services) compiler and backends", | ||
@@ -5,0 +5,0 @@ "homepage": "https://cap.cloud.sap/", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3847280
131
74073
11