jdaugherty commented on code in PR #16583:
URL: https://github.com/apache/grails-core/pull/16583#discussion_r4348899041
##########
grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/validation/constraints/builtin/UniqueConstraint.groovy:
##########
@@ -157,6 +157,9 @@ class UniqueConstraint extends AbstractConstraint {
}
}
eq(propName, value)
+ } else {
+ // null is compared as a value: only a row whose
value is also null conflicts
+ isNull(propName)
Review Comment:
This hard-codes the `isNull` reading from [my comment on
#14503](https://github.com/apache/grails-core/issues/14503#issuecomment-4375499276).
We want that reading, the skip reading and today's wildcard behaviour all
available behind a toggle, with the default decided on the issue rather than
here.
The constraints DSL cannot take a sibling key for it: `url unique:
'httpMethod', nulls: 'skip'` would register `nulls` as another constraint. So
the per-constraint form has to be a Map parameter along the lines @homicki
proposed, `unique: [group: ['httpMethod'], nulls: ...]`, which means
`validateParameter` and the constructor accept a Map next to the `Iterable` and
`CharSequence` forms. A GORM-wide setting should supply the default so an
application sets its rule once instead of on every constraint. Names to taste;
the three semantics are what matter.
--
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]