[Dbix-class] RFC: Round two for UNIQUE constraints

Matt S Trout dbix-class at trout.me.uk
Sun Jan 22 16:45:50 CET 2006


On Sat, Jan 21, 2006 at 09:44:38PM -0500, Daniel Westermann-Clark wrote:
> So, I thought I'd give UNIQUE constraint support another try now that
> the resultset refactoring is settling down.  It was discussed briefly
> before:
> 
> http://lists.rawmode.org/pipermail/dbix-class/2005-December/000385.html
> 
> It's pretty much the same code this time around, but now it's folded
> into ResultSet and ResultSource.
> 
> Suggestions?  Is it something to consider for 0.05?

Looks pretty good, although I think the constraints should be named, since
everything else is.
 
> One comment from last time around which I haven't taken into account:
> 
> > I think arguably find, find_or_create, etc. should all default to
> > operating on the PK but be able to operate on any unique key, maybe
> > with a { key => ... } attribute. The find methods don't currently
> > take attributes, sadly, which will be Getting Fixed as I move them
> > over onto the ResultSet object.
> 
> I'm concerned that this would require some slightly ugly API changes
> to find and find_or_create, since currently they allow you to specify
> a flat list of values.

So? So does search.

$rs->find(pk1 => $val1, pk2 => $val2, %attrs);

should be implementable; search already accepts this syntax.

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list