I created one custom attibute for customer. and make unique value true. while we edit customer in admin panel , and trying to save, its always give error like attribute should be unique. but their value is already unique.
I created the attribute like this:
if(version_compare($context->getVersion(), '1.1.9','<')) {
$customerSetup->addAttribute(Customer::ENTITY, 'mobile_number', [
'type' => 'text',
'label' => 'Mobile Number',
'input' => 'text',
'backend' => '',
'frontend' => '',
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'required' => false,
'visible' => true,
'user_defined' => false,
'unique' => true,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'position' => 112,
'system' => 0,
'source' => ''
]);
$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'mobile_number')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_account_edit'],
]);
$attribute->save();
}