[Dbix-class] find_or_create and unique constraints
Bill Moseley
moseley at hank.org
Sun Oct 3 13:16:35 GMT 2010
On Sun, Oct 3, 2010 at 12:43 AM, Peter Rabbitson
<rabbit+dbic at rabbit.us<rabbit%2Bdbic at rabbit.us>
> wrote:
> 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 n=
ot
>> include ALL the columns in the constraint.
>>
>
> DBIx::Class is a tool, it does not enforce "design cleanliness". Heck it
> even works with pk-less tables if need be, there is a ton of crappy
> preexisting schemas out there. To get what you want simply turn on
> FATAL warnings and perl will DTRT :)
>
Well, I wish the code for our products was that clean, but it's just not
there yet. Living with some warnings is different than a database that is
not updated as expected, though.
But, limiting the discussion to what someone using DBIC might expect, and
how DBIC might help them, if one does this:
__PACKAGE->add_unique_constraint( name =3D> [qw/ one two three /] );
then:
$rs->find_or_create({
one =3D> 1,
two =3D> 2,
three =3D> 3,
other =3D> 123,
});
would they not expect that all those columns would be set in the database?
> Btw how is the patch for find_or_create coming along?
>
It has recently moved up a page the jira dashboard.
-- =
Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20101003/107=
e3315/attachment.htm
More information about the DBIx-Class
mailing list