Skip to content

Issues with UniqueColumns constraints with nullable fields #457

Answered by igormorgado
igormorgado asked this question in Q&A
Discussion options

You must be logged in to vote

I found out the solution:

Postgres cannot handle unique constrains with Nullable fields since Null != Null. As explained ins this SO post.

A possible solution is to create partial indexes, without the nullable fields, but that is impractical with 4 them because I would need a 4! - 4 constraints.

Another alternative is to use COALESCE. I think I will find out another solution.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by igormorgado
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant