Backported #7072 to 3-2-stable. Use database value for uniqueness validation scope

I think #7072 is a bug. so it should be backported to 3-2-stable.