@sap/cds-compiler
Advanced tools
Comparing version 3.9.8 to 3.9.10
@@ -10,2 +10,12 @@ # ChangeLog for cds compiler and backends | ||
## Version 3.9.10 - 2023-08-25 | ||
### Fixed | ||
- to.edm(x): Error reporting for incorrect handling of "Collection()" has been improved. | ||
- to.sql/hdi/hdbcds: Views on views with parameters did not have localized convenience views based on | ||
other localized views (missing `localized.` prefix in FROM clause) | ||
- to.sql: Casting expressions to a structured type yields a proper error instead of strange compiler error. | ||
- to.sql.migration: Don't drop-create views marked with `@cds.persistence.exists` or `@cds.persistence.skip` | ||
## Version 3.9.8 - 2023-08-03 | ||
@@ -12,0 +22,0 @@ |
@@ -378,4 +378,3 @@ /** @module API */ | ||
// TODO: exists, abstract? isPersistedOnDb? | ||
if (diffArtifact && diffArtifact['@cds.persistence.name'] && !diffArtifact['@cds.persistence.skip'] && | ||
(diffArtifact.query || diffArtifact.projection) && | ||
if (diffArtifact && diffArtifact['@cds.persistence.name'] && csnUtils.isPersistedAsView(diffArtifact) && | ||
(diffArtifact[modelCompare.isChanged] === true || // we know it changed because we compared two views | ||
@@ -388,2 +387,3 @@ diffArtifact[modelCompare.isChanged] === undefined)) { // if it was removed in the after, then we don't have the flag | ||
diffArtifact.kind === beforeArtifact.kind && // detect action -> entity | ||
csnUtils.isPersistedAsTable(diffArtifact) === csnUtils.isPersistedAsTable(beforeArtifact) && // detect removal of @cds.persistence.exists | ||
csnUtils.isPersistedAsView(diffArtifact) === csnUtils.isPersistedAsView(beforeArtifact) // detect view -> entity | ||
@@ -390,0 +390,0 @@ ) { // don't render again, but need info for primary key extension |
@@ -745,2 +745,10 @@ // Central registry for messages. | ||
'type-invalid-cast': { | ||
std: 'Invalid cast to $(TYPE)', // unused | ||
'to-structure': 'Can\'t cast to a structured type', | ||
'from-structure': 'Structured elements can\'t be cast to a different type', | ||
'expr-to-structure': 'Can\'t cast an expression to a structured type', | ||
'val-to-structure': 'Can\'t cast $(VALUE) to a structured type' | ||
}, | ||
// ----------------------------------------------------------------------------------- | ||
@@ -853,3 +861,3 @@ // Expressions | ||
'std': 'Unexpected value $(VALUE) for $(ANNO) of type $(TYPE)', | ||
'struct': 'Unexpected $(STR) value for $(ANNO) of type $(TYPE)', | ||
'incompval': 'Unexpected $(STR) value for $(ANNO) of type $(TYPE)', | ||
'nestedcollection': 'Nested collections are not supported for $(ANNO)', | ||
@@ -856,0 +864,0 @@ 'enumincollection': 'Enum inside collection is not supported for $(ANNO)', |
@@ -519,10 +519,6 @@ // Compiler phase "resolve": resolve all references | ||
if (elem && art.type) { // has explicit type | ||
if (art.type._artifact?.elements) { | ||
error('type-cast-to-structured', [ art.type.location, art ], {}, | ||
'Can\'t cast to structured element'); | ||
} | ||
else if (elem.elements) { // TODO: calc elements | ||
error('type-cast-structured', [ art.type.location, art ], {}, | ||
'Structured elements can\'t be cast to a different type'); | ||
} | ||
if (art.type._artifact?.elements) | ||
error( 'type-invalid-cast', [ art.type.location, art ], { '#': 'to-structure' } ); | ||
else if (elem.elements) // TODO: calc elements | ||
error( 'type-invalid-cast', [ art.type.location, art ], { '#': 'from-structure' } ); | ||
} | ||
@@ -529,0 +525,0 @@ } |
@@ -21,9 +21,7 @@ 'use strict'; | ||
* @param {object} messageFunctions | ||
* @param {Function} messageFunctions.error | ||
* @param {Function} messageFunctions.info | ||
* @param {Function} messageFunctions.throwWithAnyError | ||
* @param {object} csnUtils | ||
* @param {object} [iterateOptions] | ||
*/ | ||
function expandStructureReferences( csn, options, pathDelimiter, { error, info, throwWithAnyError }, csnUtils, iterateOptions = {} ) { | ||
function expandStructureReferences( csn, options, pathDelimiter, messageFunctions, csnUtils, iterateOptions = {} ) { | ||
const { error, info, throwWithAnyError } = messageFunctions; | ||
const { | ||
@@ -36,3 +34,2 @@ isStructured, get$combined, getFinalTypeInfo, | ||
applyTransformations(csn, { | ||
@@ -543,2 +540,14 @@ keys: (parent, name, keys, path) => { | ||
} | ||
else if (col.cast?.type) { | ||
// TODO: Support expanding `null as field : StructuredT` | ||
const _art = col.cast._type || inspectRef(path.concat(i, 'cast', 'type')).art; | ||
if (_art && isStructured(_art)) { | ||
error('type-invalid-cast', path.concat(i, 'cast', 'type'), { | ||
'#': col.val !== undefined ? 'val-to-structure' : 'expr-to-structure', value: col.val, | ||
}); | ||
} | ||
else { | ||
newThing.push(col); | ||
} | ||
} | ||
else { | ||
@@ -545,0 +554,0 @@ newThing.push(col); |
@@ -16,2 +16,3 @@ 'use strict'; | ||
} = require('../model/csnUtils'); | ||
const {CompilerAssertion} = require('../base/error'); | ||
@@ -581,10 +582,18 @@ /** | ||
const ref = Array.isArray(obj.ref) ? obj.ref[0] : obj.ref; | ||
if (typeof ref !== 'string') | ||
return; | ||
const def = csn.definitions[ref]; | ||
if (def && def[_hasLocalizedView]) { | ||
if (Array.isArray(obj.ref)) | ||
obj.ref[0] = def[_hasLocalizedView]; | ||
else | ||
if (typeof ref === 'string') { | ||
const def = csn.definitions[ref]; | ||
if (def && def[_hasLocalizedView]) { | ||
if (Array.isArray(obj.ref)) | ||
obj.ref[0] = def[_hasLocalizedView]; | ||
else | ||
obj.ref = def[_hasLocalizedView]; | ||
} | ||
} else if (ref.id) { | ||
const def = csn.definitions[ref.id]; | ||
if (def && def[_hasLocalizedView]) | ||
obj.ref[0].id = def[_hasLocalizedView]; | ||
} else if (options.testMode) { | ||
throw new CompilerAssertion('Debug me: Unhandled reference during localized-rewrite!'); | ||
} | ||
@@ -591,0 +600,0 @@ } |
{ | ||
"name": "@sap/cds-compiler", | ||
"version": "3.9.8", | ||
"version": "3.9.10", | ||
"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
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
4426047
88517