duplicateKeyIs function
Whether error names expected as the colliding key.
A 2627 on a different unique index is not a getOrCreate hit: the insert failed because some other column collided, and returning an existing row for the requested key would hide that.
Implementation
bool duplicateKeyIs(MssqlException error, String expected) {
if (!_isDuplicateKey(error)) return false;
final named = duplicateKeyName(error.message);
if (named == null) return false;
return named.toLowerCase() == expected.toLowerCase();
}