[CDBI] Fwd: find_or_create() barfs with constraints
perl at rhesa.com
Tue Aug 2 20:17:29 BST 2005
Aaron Turner 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.
> __PACKAGE__->columns(All => qw/variant_typeID suite_typeID
> next_mutationID name description/);
You should inform Class::DBI about the multi-column primary key:
__PACKAGE__->columns(Primary => qw/variant_typeID suite_typeID/);
then add the other columns:
__PACKAGE__->columns(Essential => qw/next_mutationID name
> # Note that there is a unique key over suite_typeID/name
If you only supply the All column group, Class::DBI assumes the first
column is your primary key. In most cases that is sufficient, but in
this case you need to be explicit.
Hope that helps,
More information about the ClassDBI