Re: [CDBI] Fwd: find_or_create() barfs with constraints

[prev] [thread] [next] [Date index for 2005/08/03]

From: Aaron Turner
Subject: Re: [CDBI] Fwd: find_or_create() barfs with constraints
Date: 01:52 on 03 Aug 2005
The exact error I get is:

DBD::Pg::st execute failed: ERROR:  duplicate key violates unique  
constraint "variant_type.name_suite"
[for Statement "INSERT INTO mucore.variant_type (name, suite_typeid,  
variant_typeid)
VALUES (?, ?, ?)
" with ParamValues: 2='3', 1='invalid-length', 3='11'] at /usr/lib/ 
perl5/site_perl/5.8.5/DBIx/ContextualFetch.pm line 51, <DIGEST> line  
559.

The issue here of course is that variant_type.name_suite is a unique  
key on the suite_typeid and name columns, which is what I pass to  
find_or_create().  The variant_type table has a separate PK/sequence  
(variant_typeid).

It appears to be that find_or_create() isn't finding the record, and  
is then trying to re-insert it.


        -- 
        Aaron Turner, Sr. Security Engineer                        
<aturner@xxxxxxxxxx.xxx>


On Aug 2, 2005, at 6:24 PM, Peter Speltz wrote:

> On 8/2/05, Aaron Turner <aturner@xxxxxxxxxx.xxx> wrote:
>
>>
>> I'm looking to insert a record in table if it doesn't already exist.
>> I've also created a unique key (across two columns) to prevent other
>> access not via Class::DBI from causing problems.
>>
>> The issue seems however that when I do a Object->find_or_create
>> ({ col1 => 'value', col2 => 'value'}) I get an error when it
>> apparently tries to insert a duplicate record.
>>
>>
>
> whats the error?  Are you sure it is the MK causing problem. It is
> weird that it would not find your row.
>
>
> --
> pjs
>
>


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

(message missing)

Re: [CDBI] Fwd: find_or_create() barfs with constraints
Aaron Turner 01:52 on 03 Aug 2005

Generated at 09:40 on 09 Aug 2005 by mariachi v0.52