Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 51409
Status: resolved
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: Dave [...] WolfeWorks.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.08113



Subject: _cond_for_update_delete doesn't handle SCALAR conditions
Date: Tue, 10 Nov 2009 22:23:52 -0600
To: bug-DBIx-Class [...] rt.cpan.org
From: Dave Wolfe <Dave [...] WolfeWorks.net>
Ubuntu 9.10 generic with latest updates Perl 1.10.0 Catalyst 5.80002 DBIx::Class 0.08112 Retrieving a result set via a search request works as expected: my $map = $c->model('DB::Contactmap')->search( { classification => $class }, { where => \"sequence BETWEEN $lower AND $upper", order_by => 'sequence', for => 'update' }); When I attempt to modify this result set via an update request: $map->update({ sequence => \'sequence - 1', version => \'version + 1' }) || return (undef, 'Contact order change failed'); it throws the error: [debug] DBIx::Class::ResultSet::update(): DBI Exception: DBD::mysql::st execute failed: FUNCTION stmaustin.SCALAR does not exist [for Statement "UPDATE ContactMap SET sequence = sequence - 1, version = version + 1 WHERE ( ( classification = ? AND SCALAR(0x6d2e6b8) IS NULL ) )" with ParamValues: 0=ministry] at /home/httpd/vhosts/stm2/script/../lib/STM/Controller/Admin/Contactmap.pm line 466 The code in _cond_for_update_delete (in DBIx::Class::ResultSet.pm) modifies the result set condition to "handle the differing SQL syntax available". It's failing to properly handle a reference to a scalar for DB functions, as used above, and tries to use the scalar ref as a hash key, which subsequently fails as SQL. The schema file is: -------------------- Begin Contactmap.pm -------------------- package STM::Schema::Result::Contactmap; use strict; use warnings; use base 'DBIx::Class'; __PACKAGE__->load_components("InflateColumn::DateTime", "Core"); __PACKAGE__->table("ContactMap"); __PACKAGE__->add_columns( "contentid", { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, "contactid", { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, "version", { data_type => "INT", default_value => 0, is_nullable => 0, size => 10 }, "position", { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 70, }, "publish", { data_type => "ENUM", default_value => undef, is_nullable => 0, size => 5 }, "classification", { data_type => "ENUM", default_value => undef, is_nullable => 0, size => 12 }, "sequence", { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, ); __PACKAGE__->set_primary_key("contentid", "contactid"); # Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-06-22 15:50:14 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:M/pXgkR/I5DRP2EQOs/Q0Q __PACKAGE__->belongs_to(contentpage => 'STM::Schema::Result::Content', 'contentid'); __PACKAGE__->belongs_to(pagecontact => 'STM::Schema::Result::Contacts', 'contactid'); 1; -------------------- End Contactmap.pm -------------------- -- Dave Wolfe
Unfortunately _cond_for_update_delete doesn't handle a lot of other things, so it went to meet its maker: http://dev.catalyst.perl.org/svnweb/bast/revision/?rev=7869 Thanks for the report