[Dbix-class] Unique constraint isn't good enough for update_or_create?

Darren Duncan darren at darrenduncan.net
Thu Nov 12 06:21:35 GMT 2009


Sean McAfee wrote:
> I have a table that doesn't have a primary key, but does a unique 
> index.  When I call update_or_create on this table, I can create the row 
> just fine, but when I try to update it with a second call, this 
> exception gets thrown:
> 
> Cannot safely update a row in a PK-less table
> 
> But the documentation for DBIx::Class::ResultSet explicitly says that 
> the method can use unique constraints.  So why isn't it?

Does your table have multiple unique constraints or just one?

 From my quick reading, the ResultSet documentation appears to be saying you 
need to provide an explicit 'key' attribute value when a match is being done on 
a non-primary key (aka unique constraint), rather than it figuring things out 
for itself if you have exactly 1 unique constraint.  Have you set 'key' explicitly?

-- Darren Duncan



More information about the DBIx-Class mailing list