During our upgrade to CAP CDS 8, my colleague @vvdries and me encountered a number of ‘challenges’ to be tackled. In this document, we aim to share our findings with you.
This living document not only highlights what we’ve learned but also invites the community to contribute their own bugs and fixes. Our goal is to update this post regularly with new insights, additional bugs, or improved solutions. So, feel free to share your experiences and fixes in the comments.
A general advise is to plan this upgrade. According to the size of your project lot of testing is needed, and fixing all issues might take up a lot of time.
Finding 1: Entities Must Have a Key
If you did not provide keys, just simply add them and do NOT suppress the error message with a warning as this will only cause other issues.
If you have calculated associations, where there is no key, you can use types. (Be aware that according to the oData spec each entity should have a key)
@cds.persistense.skip
entity NonpersistentEntity { //Filled in handler
propA: Decimal;
propB: String;
}
type NonPersistent: Association to NonpersistentEntity;
entity persistentEntity: cuid {
propC:Boolean;
propD:Date;
oneCalculatedEntity: NonPersistent;
manyCalculatedEntities: array of NonPersistent;
}
Finding 2: Large queries fail
The issue caused by the system exceeding the default maximum packet size, was fixable by applying the instruction from this note: MAX_PACKET_SIZE = Math.pow(2,18). The hdb module is now included in the @sap-js/hana module (Using SAP HANA Cloud for Production | capire) as default driver, where these parameters are read from a different place, the package.json file.
So to solve this you need to set the parameters in the package.json file:
“cds”: {
“requires”: {
“[production]”: {
“db”: {
“kind”: “hana”,
“credentials”: {
“packetSize”: 1073741823,
“packetSizeLimit”: 1073741823
}
}
}
}
Finding 3: Omitting/time-traveling temporal on CDS model/service level does not work anymore
Before CDS 8 it was possible to retrieve all entries from a table with temporal aspect, meaning also those that are not valid anymore according to the current date. This was possible using these annotations, as stated in these release notes. The where-clause for the validity date was omitted in the generated Hana Cloud DB view.
//Entity with temporal aspect (validFrom/validTo)
entity temporalEntity : cuid, temporal {
value : Decimal;
}
//Omit temporal aspect
define view allEntities as
select from temporalEntity {
key ID,
@(cds.valid.from: false)
key validFrom,
@(cds.valid.to: false)
validTo,
value
}
When switching to CDS 8 the @SAP/cds-compiler node also needed to be upgraded, and we noticed only ‘valid’ entries were retrievable from the database, meaning selecting an entry where the current date is not between validFrom and validTo was not possible anymore. To activate this again you need to activate this (now beta…) feature in the package.json:
Please note retrieving ‘invalid’ entries is also possible in a handler by selecting directly from the database instead of the service or using odata url parameters This finding only concerns CDL.
“cds”: {
“cdsc”: {
“beta”: {
“temporalRawProjection”: true
}
}
}
Finding 4: A deep create (oData) produced error: Property “x” does not exist in XXXItemSet
The new Protocol Adapters (GA) causes logic errors when sending a create payload containing an association. They should only be creatable when it is a composition. You can skip this by adding the feature below, but don’t!
cds.features.odata_new_adapter = false
As CAP docu mentions in new cds upgrades this will not be available anymore.
To fix this we used the annotation @CDS.validate: false on the association. Although this fixes this issue, it does not seem like a good or permanent solution. This issue was also raised in this post
Ideally an associated entity is not part of the payload when creating a new entry, but this is not always possible.
entity Parent : cuid {
propA : Decimal;
propB : String;
@cds.validate: false
childEntities : Association to Child;
}
During our upgrade to CAP CDS 8, my colleague @vvdries and me encountered a number of ‘challenges’ to be tackled. In this document, we aim to share our findings with you.This living document not only highlights what we’ve learned but also invites the community to contribute their own bugs and fixes. Our goal is to update this post regularly with new insights, additional bugs, or improved solutions. So, feel free to share your experiences and fixes in the comments.A general advise is to plan this upgrade. According to the size of your project lot of testing is needed, and fixing all issues might take up a lot of time.Finding 1: Entities Must Have a KeyIf you did not provide keys, just simply add them and do NOT suppress the error message with a warning as this will only cause other issues.If you have calculated associations, where there is no key, you can use types. (Be aware that according to the oData spec each entity should have a key) @cds.persistense.skip
entity NonpersistentEntity { //Filled in handler
propA: Decimal;
propB: String;
}
type NonPersistent: Association to NonpersistentEntity;
entity persistentEntity: cuid {
propC:Boolean;
propD:Date;
oneCalculatedEntity: NonPersistent;
manyCalculatedEntities: array of NonPersistent;
} Finding 2: Large queries failThe issue caused by the system exceeding the default maximum packet size, was fixable by applying the instruction from this note: MAX_PACKET_SIZE = Math.pow(2,18). The hdb module is now included in the @sap-js/hana module (Using SAP HANA Cloud for Production | capire) as default driver, where these parameters are read from a different place, the package.json file. So to solve this you need to set the parameters in the package.json file: “cds”: {
“requires”: {
“[production]”: {
“db”: {
“kind”: “hana”,
“credentials”: {
“packetSize”: 1073741823,
“packetSizeLimit”: 1073741823
}
}
}
} Finding 3: Omitting/time-traveling temporal on CDS model/service level does not work anymoreBefore CDS 8 it was possible to retrieve all entries from a table with temporal aspect, meaning also those that are not valid anymore according to the current date. This was possible using these annotations, as stated in these release notes. The where-clause for the validity date was omitted in the generated Hana Cloud DB view. //Entity with temporal aspect (validFrom/validTo)
entity temporalEntity : cuid, temporal {
value : Decimal;
}
//Omit temporal aspect
define view allEntities as
select from temporalEntity {
key ID,
@(cds.valid.from: false)
key validFrom,
@(cds.valid.to: false)
validTo,
value
} When switching to CDS 8 the @SAP/cds-compiler node also needed to be upgraded, and we noticed only ‘valid’ entries were retrievable from the database, meaning selecting an entry where the current date is not between validFrom and validTo was not possible anymore. To activate this again you need to activate this (now beta…) feature in the package.json:Please note retrieving ‘invalid’ entries is also possible in a handler by selecting directly from the database instead of the service or using odata url parameters This finding only concerns CDL. “cds”: {
“cdsc”: {
“beta”: {
“temporalRawProjection”: true
}
}
} Finding 4: A deep create (oData) produced error: Property “x” does not exist in XXXItemSetThe new Protocol Adapters (GA) causes logic errors when sending a create payload containing an association. They should only be creatable when it is a composition. You can skip this by adding the feature below, but don’t! cds.features.odata_new_adapter = false As CAP docu mentions in new cds upgrades this will not be available anymore.To fix this we used the annotation @CDS.validate: false on the association. Although this fixes this issue, it does not seem like a good or permanent solution. This issue was also raised in this postIdeally an associated entity is not part of the payload when creating a new entry, but this is not always possible. entity Parent : cuid {
propA : Decimal;
propB : String;
@cds.validate: false
childEntities : Association to Child;
} Read More Technology Blogs by Members articles
#SAP
#SAPTechnologyblog