On Fri, Jul 28, 2006 at 12:16:52AM -0400, Daniel Westermann-Clark wrote:
> 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.

Thank you for the amazingly quick fix, and for the warning.  Since I'm
using SQLite, I've changed my Schema to declare ROWID (the built in
primary key) as the primary key, and updates seem to be working.

---------------------------------------------------------------------
package App::Model::DB::Schema::Rating;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/Core PK::Auto/);
__PACKAGE__->table('rating');
__PACKAGE__->add_columns(qw/ROWID uid iid score flags/);
__PACKAGE__->set_primary_key(qw/ROWID/);
__PACKAGE__->add_unique_constraint(uid_iid => [ qw/uid iid/ ]);
---------------------------------------------------------------------

Thanks!

--nate


_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to