addEmailAddress: redundant add w/ same address.
This should succeed as the previous tests show. They now pass: ok 21 - addEmailAddress: fails adding existing email address with mismatched type. ok 22 - addEmailAddress: succeeds when adding email that already exists... ok 23 - addEmailAddress: ... and returns same id.
This commit is contained in:
parent
e10f8ed61a
commit
501355b839
1 changed files with 12 additions and 2 deletions
|
@ -201,9 +201,19 @@ sub addEmailAddress($$$$) {
|
|||
unless defined $emailAddressType and Mail::RFC822::Address::valid($emailAddress);
|
||||
|
||||
my $existingEmail = $self->_lookupEmailAddress($emailAddress);
|
||||
die "addEmailAddress: attempt to add email address that exists, using a different type!"
|
||||
if defined $existingEmail and $existingEmail->{type} ne $emailAddressType;
|
||||
|
||||
if (defined $existingEmail) {
|
||||
die "addEmailAddress: attempt to add email address that exists, using a different type!"
|
||||
if $existingEmail->{type} ne $emailAddressType;
|
||||
|
||||
my $val = $self->dbh()->selectall_hashref("SELECT email_address_id, donor_id " .
|
||||
"FROM donor_email_address_mapping WHERE " .
|
||||
"donor_id = " . $self->dbh->quote($id, 'SQL_INTEGER') . " AND " .
|
||||
"email_address_id = " . $self->dbh->quote($existingEmail->{id}, 'SQL_INTEGER'),
|
||||
'donor_id');
|
||||
return $val->{$id}{email_address_id}
|
||||
if (defined $val and defined $val->{$id} and defined $val->{$id}{email_address_id});
|
||||
}
|
||||
my($sth, $addressId);
|
||||
|
||||
$self->_beginWork();
|
||||
|
|
Loading…
Reference in a new issue