[Dbix-class] update_or_create and add_unique_constraint
Daniel Westermann-Clark
dwc at pobox.com
Fri Jul 28 06:16:52 CEST 2006
On 2006-07-27 20:13:17 -0600, Nathan Kurz wrote:
> Glancing at the source, it looks like
> DBIx::Class::ResultSet::update_or_create() is accepting both $cond
> and $attr, but only passes $cond on to find. And it looks like
> DBIx::Class::ResultSet::find() will use unique contraints if passed
> them, but only searches for primary columns if given nothing.
This is true. I've added a fix (and test) for this to trunk, which
will be in the next release.
http://dev.catalyst.perl.org/trac/bast/changeset/2643
However, it's important to note that DBIx::Class cannot currently
update a row based on a unique constraint. You'll get an error about
not being able to safely update the row on a PK-less table.
So for now you'll have to add a primary key to your table.
Promoting unique constraints to a full Row subclass is probably the
most sensible option going forward. I'll try to open a branch for
this over the weekend. Though since 0.07 is in its stable release
cycle, it won't be released until 0.08.
--
Daniel Westermann-Clark
More information about the Dbix-class
mailing list