matrei opened a new pull request, #16474:
URL: https://github.com/apache/grails-core/pull/16474

   Fixes #16473
   
   With `grails.gorm.default.nullable: false`, `importFrom` copied a property 
the source domain class leaves unconstrained as `nullable: true`. Command 
objects and domain classes that import constraints from such a domain class 
then accepted `null` where the domain class itself does not.
   
   `importFrom` evaluated the source class with a new 
`DefaultConstraintEvaluator`, which always uses the framework's nullable 
default and so ignored the configured one. It now uses the evaluator that is 
evaluating the importing class, so the source class gets the same defaults.
   
   ### Changes
   
   - `DefaultConstraintEvaluator.newConstrainedPropertyBuilder` passes the 
evaluator to the builder, and `importFrom` evaluates the source class with it. 
The existing `ConstrainedPropertyBuilder` constructor is kept, and falls back 
to the previous behaviour.
   - `ImportFromSpec` and `DefaultConstraintEvaluatorSpec` check, with the 
default set to `false` and to `true`, that a property the source leaves 
unconstrained follows the configured default, both for a domain class and for a 
command object, and that explicit constraints are imported unchanged.
   - A new `ImportFromDefaultNullableSpec` for Hibernate 5 and Hibernate 7 
checks the same through `validate()` and `save()`, with 
`grails.gorm.default.nullable: false` set in the datastore configuration.
   - The `importFrom` documentation in the validation guide and the constraints 
reference says which nullable default imported properties get. The 8.0 upgrade 
guide now notes that this is an exception to "command objects are unaffected".
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to