[Dbix-class] find_or_create and unique constraints

Daniel Westermann-Clark dwc at pobox.com
Sun Oct 3 15:19:03 GMT 2010


On 2010-10-02 17:16:20 -0700, Bill Moseley wrote:
> I'm wondering if find_or_create should throw an exception if a unique
> constraint does not exist or if the values passed to find_or_create do not
> include ALL the columns in the constraint.

I wrote some code long ago that attempted to do this (see
_is_unique_query in ResultSet.pm), but it breaks down on any sort of
complex query.  Anything with a join, for example, is hard to analyze
against unique constraints.

I'm actually surprised that code still lives in ResultSet.pm.  :)

The compromise was to have single return a warning when more than one
row is returned, gently nudging people to be more careful.

-- 
Daniel Westermann-Clark



More information about the DBIx-Class mailing list