[Dbix-class] Using update on a resultset with join
Trevor Leffler
tleffler at uw.edu
Wed May 5 00:27:33 GMT 2010
I'm stuck with (at the moment) version 0.08011 of DBIC, so please let me
know if a newer version addresses this issue.
I'm creating a resultset of source 'Foo', joining against one or more
other sources, and then trying to update, assuming that the update would
work against 'Foo' and not the joined-in tables. Here's what I've got:
package My::Schema::ResultSet::Foo
...
sub mark_as_exported {
...
$self->search(
{me.exported = 0, bar.state = 'WA'},
{join => 'bar'}
)->update({exported = 1});
...
}
This DBIC tracefile is produced:
$ less /tmp/trace.out
UPDATE foo SET exported = ? WHERE ( ( exported = ? AND state = ? AND )
): '1', '0', 'WA'
Whereas I was expecting SQL like:
UPDATE foo me JOIN ( bars bar ON bars.id = me.bar_id ) SET me.exported =
1 WHERE ( me.exported = 0 AND bar.state = 'WA' )
Thanks,
--Trevor
More information about the DBIx-Class
mailing list