[CDBI] Fwd: find_or_create() barfs with constraints

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

From: Aaron Turner
Subject: [CDBI] Fwd: find_or_create() barfs with constraints
Date: 18:54 on 02 Aug 2005
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.

For what it's worth:

Class::DBI 0.96
DBD::Pg 1.43
Class::DBI::Pg 0.6
PostgreSQL 8.0.3

The offending code:
$VT = Mu::VariantType->find_or_create({ name => $variant,
         suite_typeID => $ST->id });

My object:
package Mu::VariantType;
use lib '..';
use base 'Mu::DBI';
use Mu::MutationVariant;
use Mu::VariantCategory;
use Mu::SuiteType;
use Mu::TestGroupVariant;

__PACKAGE__->table('mucore.variant_type');
__PACKAGE__->sequence('mucore.variant_type_variant_typeid_seq');
__PACKAGE__->columns(All => qw/variant_typeID suite_typeID  
next_mutationID name description/);

# Note that there is a unique key over suite_typeID/name

#_PACKAGE__->has_many('mutations', Mu::MutationVariant =>  
'variant_typeID' );
__PACKAGE__->has_many(categories => [ Mu::VariantCategory =>
     'category_typeID' ]);
__PACKAGE__->has_a(suite_typeID => 'Mu::SuiteType');
__PACKAGE__->has_many(test_groups => [ Mu::TestGroupVariant =>  
'test_groupID' ]);

1;
__END__

Note that Mu::DBI's base is Class::DBI::Pg.

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




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

(message missing)

[CDBI] Fwd: find_or_create() barfs with constraints
Aaron Turner 18:54 on 02 Aug 2005

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