From b55cce3e63dd48a81f8964c1a5ea9ad356208c7e Mon Sep 17 00:00:00 2001 From: Daniel Hutzel Date: Wed, 16 Jul 2025 13:49:45 +0200 Subject: [PATCH] case when equivalent --- bookshop/srv/x-validation.cds | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bookshop/srv/x-validation.cds b/bookshop/srv/x-validation.cds index 3ef7b696..c5f67ce1 100644 --- a/bookshop/srv/x-validation.cds +++ b/bookshop/srv/x-validation.cds @@ -8,8 +8,12 @@ using from '../db/schema'; view Books.constraints as select from Books { ID, // two-step mandatory check - title = null ? 'is missing' : trim(title)='' ? 'must not be empty' : - null as title, + case + when title is null then 'is missing' + when trim(title)='' then 'must not be empty' + end as title, + // the above is equivalent to: + // title is null ? 'is missing' : trim(title)='' ? 'must not be empty' : // range check stock < 0 ? 'must not be negative' :