[Dbix-class] find_or_create duplicate entry errors

Jason Konrad jason at popularmedia.com
Sun Jun 17 19:07:58 GMT 2007


I've been seeing this error which I thought should never happen due to the
attempt to find by the key before creating a new record.

"DBIx::Class::ResultSet::find_or_create(): Error executing 'INSERT INTO
recipients (ciphered_email, domain, hashed_email_id) VALUES (?, ?, ?)':
Duplicate entry '1500' for key 2


Here is the corresponding code that is causing the error.

       $recipient = $c->model('kRadDB::Recipients')->find_or_create(
            {
                hashed_email_id => $hashed_email_id,
                domain          => $domain,
                ciphered_email  => $cipher->encrypt_hex($contact),
            },
            {
                key => 'hashed_email_id'
            }
        );


Any ideas on how to stop this error from happening?


Thanks,
  JK




More information about the Dbix-class mailing list