Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip(POC): @assert.constraint #988

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4bdde0d
wip: assert constraint poc
patricebender Jan 20, 2025
665e38d
wip: need to rollback transaction
patricebender Jan 21, 2025
dfc4a1b
rollback the tx
patricebender Jan 21, 2025
6c2528c
add insert test
patricebender Jan 21, 2025
6fe6973
batch handling for inserts
patricebender Jan 21, 2025
ebf8ae2
add removed file
patricebender Jan 21, 2025
b4df5e0
wip: aggregations
patricebender Jan 21, 2025
67988fc
validate an aggregation
patricebender Jan 23, 2025
a738b9d
Merge remote-tracking branch 'origin/main' into patrice/assert-constr…
patricebender Jan 23, 2025
f334fe6
no stock is okay
patricebender Jan 23, 2025
c133b03
dummy decimal for our POC
patricebender Jan 23, 2025
46c1a91
wip: deferred constraints test
patricebender Jan 30, 2025
db00424
proper test expectations
patricebender Jan 30, 2025
2254c3c
get test right
patricebender Jan 30, 2025
6756f60
wip: defer constraints
patricebender Jan 30, 2025
73c3dc8
defer constraint check to before commit
patricebender Jan 30, 2025
3a8b939
remove todo
patricebender Jan 30, 2025
b208fbd
Merge branch 'main' into patrice/assert-constraint
patricebender Jan 31, 2025
d640b19
try extra parens
patricebender Jan 31, 2025
5c1064b
workaround for hana
patricebender Jan 31, 2025
9752e1d
add price to a view
patricebender Jan 31, 2025
ea39c19
only needed for local testing
patricebender Jan 31, 2025
c27006f
Merge remote-tracking branch 'origin/main' into patrice/assert-constr…
patricebender Feb 12, 2025
fee4ddb
some comments
patricebender Feb 12, 2025
ca61be6
for now, no aggregation validation
patricebender Feb 12, 2025
72b6a31
focus on element level constraints
patricebender Feb 12, 2025
dc02461
correct wrong operator
patricebender Feb 12, 2025
2977e67
constraint shortcut / constraint via path
patricebender Feb 12, 2025
b9550ce
small code improvements
patricebender Feb 12, 2025
a175c52
no need to add `is null` check for unmanaged
patricebender Feb 12, 2025
7ebae5e
wip: nullability for unmanaged paths
patricebender Feb 12, 2025
65fd66c
constraint killed some tests
patricebender Feb 13, 2025
d9dfc02
add todo
patricebender Feb 14, 2025
9e3ebca
messages and parameters end to end
patricebender Feb 14, 2025
83d19ba
some more messages
patricebender Feb 14, 2025
8ca290e
allow longer genre names
patricebender Feb 14, 2025
48c6d2d
fix days_between function mapping for now
patricebender Feb 14, 2025
5ee719e
workaround
patricebender Feb 14, 2025
e576ec6
Merge remote-tracking branch 'origin/main' into patrice/assert-constr…
patricebender Feb 19, 2025
f55839f
Merge branch 'main' into patrice/assert-constraint
patricebender Mar 14, 2025
f36c922
use array for params
patricebender Mar 14, 2025
a5444e4
Merge remote-tracking branch 'origin/main' into patrice/assert-constr…
patricebender Mar 21, 2025
fd2ad86
for now no nullabiltiy 4 unmanagedf
patricebender Mar 21, 2025
ff01717
goerlsche negation
patricebender Mar 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
some comments
patricebender committed Feb 12, 2025
commit fee4ddb4075953d5e7ff3316936ed882b3c957cf
17 changes: 17 additions & 0 deletions test/bookshop/db/schema.cds
Original file line number Diff line number Diff line change
@@ -24,6 +24,23 @@ entity Books : managed {
descr : localized String(1111);
author : Association to Authors;
genre : Association to Genres default 10;
@assert.constraint.lessThanPrice: { // prefix with elem name
condition: ( stock <= price ),
message: 'The stock must be less than or equal to price: {price}'
}
// postfix name not necessary
// @assert.constraint: { //> implicit name: @assert.constraint.stock
// condition: ( stock <= price ),
// message: 'The stock must be less than or equal to price: {price}'
// }

// @assert.constraint: ( stock <= price ) //> implicit name: @assert.constraint.stock
// default message: @assert.constraint.stock failed (lookup in i18n)
//
@assert.constraint: { //> implicit name: @assert.constraint.stock
condition: ( stock <= price ),
message: '{i18n>stockLessThanPrice}'
}
stock : Integer;
price : Decimal;
// one of the tests inserts a very big decimal which