Skip to content

@assert#28

Merged
beckermarc merged 7 commits intomainfrom
assert-4.6
Jan 7, 2026
Merged

@assert#28
beckermarc merged 7 commits intomainfrom
assert-4.6

Conversation

@beckermarc
Copy link
Copy Markdown
Collaborator

No description provided.

@beckermarc beckermarc mentioned this pull request Dec 15, 2025
Comment thread pom.xml Outdated
@beckermarc
Copy link
Copy Markdown
Collaborator Author

@StefanHenke This is now also ready for review with the release of 4.6.0

end);

EndDate @assert: (case
when EndDate < BeginDate then error('ASSERT_ENDDATE_AFTER_BEGINDATE', null, (BeginDate, EndDate))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the JS variant, an additional check is used :

 when exists Bookings [Flight.date < Travel.BeginDate] then 'ASSERT_BOOKINGS_IN_TRAVEL_PERIOD'

However, the JS variant does the check again on the Travel entity (https://github.com/capire/xtravels/blob/e89c2df28511de82a35e9da5433182d283388d9f/srv/travel-constraints.cds#L22C4-L22C98).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is covered by the assertion on Flight.date. I wouldn't duplicate these errors, as it leads to multiple errors with the same reason. I'd rather refer to the BeginDate/EndDate as additional targets, but I don't think this is necessary here.

when date not between $self.Travel.BeginDate and $self.Travel.EndDate then 'ASSERT_BOOKINGS_IN_TRAVEL_PERIOD'
end);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taken from the JS variant:

Suggested change
BookingDate @assert: (case
when BookingDate > Travel.EndDate then 'ASSERT_NO_BOOKINGS_AFTER_TRAVEL'
end);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave this out for now. The BookingDate is defaulted to "today". This makes it very impractical to play around with the application when creating new bookings, as all test data is in the past. We can maybe add it later on, but I don't think it shows any additional feature, so I would leave it out for practical reasons.

Comment thread srv/travel-constraints.cds
@beckermarc beckermarc merged commit ce2910e into main Jan 7, 2026
6 checks passed
@beckermarc beckermarc deleted the assert-4.6 branch January 7, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants