I ran into an issue with this update query:
UPDATE RankingPosition rp SET rp.position = rp.position + 1 WHERE rp.ranking = :ranking AND rp.position >= :position
I have specified a unique constraint on the position column. The query violates the unique constraint.
I am wondering what I can do to get around this. It is obvious that the final state of the UPDATE would not violate the unique constraint. Unfortunately it looks like the constraint is validated after each individual update, not after the whole update statement is executed.
Is there any way I can overcome this issue?
I already checked that it is working when I remove the unique constraint, and yes, the positions are unique afterwards.