@sap/cds-compiler
Advanced tools
Comparing version 1.50.4 to 1.50.6
@@ -9,2 +9,11 @@ # ChangeLog for cdx compiler and backends | ||
## Version 1.50.6 - 2021-05-05 | ||
### Fixed | ||
- to.edm(x): | ||
+ OData V2: Render constraints only if all principal keys are used in association. | ||
+ OData V4: Don't remove `@Capabilities` annotations from containee. | ||
+ Allow `@Core.MediaType` on all types and raise a warning for those (scalar) types that can't be mapped to `Edm.String` or `Edm.Binary`. | ||
## Version 1.50.4 - 2021-04-06 | ||
@@ -11,0 +20,0 @@ |
@@ -330,4 +330,5 @@ 'use strict'; | ||
} | ||
// Remove all arget elements that are not key in the principal entity | ||
// Remove all target elements that are not key in the principal entity | ||
// and all elements that annotated with '@cds.api.ignore' | ||
const remainingPrincipalRefs = []; | ||
foreach(assocCsn._constraints.constraints, | ||
@@ -337,7 +338,18 @@ c => { | ||
// in structured mode only resolve top level element (path rewriting is done elsewhere) | ||
let fk = dependentEntity.elements[ ( options.isFlatFormat ? c[0].join('_') : c[0][0] )]; | ||
let pk = principalEntity.$keys && principalEntity.$keys[ ( options.isFlatFormat ? c[1].join('_') : c[1][0] )]; | ||
const fk = dependentEntity.elements[ ( options.isFlatFormat ? c[0].join('_') : c[0][0] )]; | ||
const principalEltRef = ( options.isFlatFormat ? c[1].join('_') : c[1][0] ); | ||
const pk = principalEntity.$keys && principalEntity.$keys[ principalEltRef ]; | ||
if(isConstraintCandidate(fk) && isConstraintCandidate(pk)) | ||
remainingPrincipalRefs.push(principalEltRef); | ||
return !(isConstraintCandidate(fk) && isConstraintCandidate(pk)); | ||
}, | ||
(c, cn) => { delete assocCsn._constraints.constraints[cn]; } ); | ||
(c, cn) => { delete assocCsn._constraints.constraints[cn]; } | ||
); | ||
// V2 check that ALL primary keys are constraints | ||
if(principalEntity.$keys) { | ||
const renderedKeys = Object.values(principalEntity.$keys).filter(isConstraintCandidate).map(v=>v.name); | ||
if(options.isV2() && intersect(renderedKeys, remainingPrincipalRefs).length !== renderedKeys.length) | ||
assocCsn._constraints.constraints = {}; | ||
} | ||
} | ||
@@ -356,2 +368,3 @@ } | ||
if(!assocCsn._target.$isParamEntity && assocCsn.keys) { | ||
const remainingPrincipalRefs = []; | ||
for(let fk of assocCsn.keys) { | ||
@@ -362,2 +375,3 @@ let realFk = assocCsn._parent.items ? assocCsn._parent.items.elements[fk.$generatedFieldName] : assocCsn._parent.elements[fk.$generatedFieldName]; | ||
{ | ||
remainingPrincipalRefs.push(fk.ref[0]); | ||
const c = [ [ fk.$generatedFieldName ], [ fk.ref[0] ] ]; | ||
@@ -367,2 +381,7 @@ const key = c.join(','); | ||
} | ||
// V2 check that ALL primary keys are constraints | ||
const renderedKeys = Object.values(assocCsn._target.$keys).filter(isConstraintCandidate).map(v=>v.name); | ||
if(options.isV2() && intersect(renderedKeys, remainingPrincipalRefs).length !== renderedKeys.length) | ||
assocCsn._constraints.constraints = {}; | ||
} | ||
@@ -369,0 +388,0 @@ } |
@@ -434,6 +434,16 @@ 'use strict'; | ||
// Check media type compatibility for all OData versions | ||
let allowedTypes = ['cds.String', 'cds.Binary', 'cds.LargeBinary']; | ||
const allowedTypes = [ | ||
'cds.String', | ||
'cds.LargeString', | ||
'cds.hana.VARCHAR', | ||
'cds.hana.CHAR', | ||
'cds.Binary', | ||
'cds.LargeBinary', | ||
'cds.hana.CLOB', | ||
'cds.hana.BINARY', | ||
]; | ||
mediaTypes.forEach(e => { | ||
if (!allowedTypes.includes(e[1].type)) { | ||
error(null, ['definitions', defName, 'elements', e[0]], `"${defName}.${e[0]}": Element annotated with '@Core.MediaType' must be of either type "${allowedTypes.join(', ')}"`); | ||
warning(null, ['definitions', defName, 'elements', e[0]], `"${defName}.${e[0]}": Element annotated with “@Core.MediaType” should be of a type mapped to "${[ 'Edm.String', 'Edm.Binary' ].join(', ')}"`); | ||
} | ||
@@ -440,0 +450,0 @@ }); |
{ | ||
"name": "@sap/cds-compiler", | ||
"version": "1.50.4", | ||
"version": "1.50.6", | ||
"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
3855254
74236