Backported #7072 to 3-2-stable. Use database value for uniqueness validation scope.
Merge pull request #9430 from authorNari/backport-7072-to-3-2-stable

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