Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: virtual element with default on service layer
  • Loading branch information
gregorwolf committed Oct 24, 2022
1 parent e8e03c9 commit d0e737f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions db/schema.cds
Expand Up @@ -50,6 +50,7 @@ entity Books : managed {
@sap.semantics : 'currency-code'
@Semantics.currencyCode
currency : Currency;
virtual virtualFromDB : String default 'Value from DB';
virtual semanticURLtoPublisher : String;
weight : DecimalFloat @title : 'Weight (DecimalFloat)';
height : Double @title : 'Height (Double)';
Expand Down
8 changes: 7 additions & 1 deletion srv/cat-service.cds
Expand Up @@ -26,7 +26,13 @@ service CatalogService @(impl : './cat-service.js') {
},
UpdateRestrictions : {Updatable : true},
DeleteRestrictions : {Deletable : true}
}, ) as projection on db.Books excluding {
}, ) as projection on db.Books {
*,
virtual 'Value from Srv' as VirtualFromSrv : String,
// Element or variable “VirtualFromSrvDefault” has not been foundCDS (compiler)(ref-undefined-var)
// Extraneous DEFAULT, expecting ‘,’, ‘.’, ‘:’, ‘(’, ‘}’, ‘@’CDS (compiler)(syntax-extraneous-token)
// virtual VirtualFromSrvDefault : String default 'Default value from Srv',
} excluding {
createdBy,
modifiedBy
} actions {
Expand Down
2 changes: 2 additions & 0 deletions tests/catalog.http
Expand Up @@ -10,6 +10,8 @@ GET http://localhost:4004/v2/catalog/
### Read Entities with OData V4
GET http://localhost:4004/catalog/
###
GET http://localhost:4004/catalog/Books
###
GET http://localhost:4004/catalog/Books
?$expand=author
### Read Books using function
Expand Down

0 comments on commit d0e737f

Please sign in to comment.