You're right that the documentation was misleading here. It said that:
UniqueConstraints
are different in this regard, in that they leverage the existing validate_unique()
logic, and thus enable two-stage validation.
What it didn't say is that that doesn't apply if you use the condition
parameter. In response to your question I added a comment on the relevant issue to suggest that this be added to the documentation, and it was.
UniqueConstraints
without a condition
(i.e. non-partial unique constraints) are different in this regard...
According to this pull request comment, the reason this isn't implemented is that... it's hard.
I feel like the appropriate solution is to completely ignore partial constraints for now... The current implementation is too naive... I suspect this will be complicated to support on all backends.
Of course, as you said, you can always override validate_unique()
yourself.