Fix uniqueness validation for inherited models.
Merge pull request #3561 from knapo/fix_uniquness_validation_for_inheritance

Fix uniqueness validation for inherited models.