[Dbix-class] calling delete in a resultset with a join

Jonas Alves jonas.alves at gmail.com
Sun Dec 2 16:12:06 GMT 2007


On Dec 2, 2007 1:51 PM, Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:
> Hi Jonas,
>
> On Nov 29, 2007 11:35 AM, Jonas Alves <jonas.alves at gmail.com> wrote:
> > Hello all,
> >
> > I', triyng to call delete in a resultset with a join. like this:
> >
> >     $schema->resultset('Movie')->search(
> >         { 'category.update_flag' => 'old' },
> >         { join => 'category' }
> >     )->delete;
> >
> >
> > The SQL I'm getting is:
> >
> > DELETE FROM movie WHERE ( update_flag = ? ): 'old'
> >
> > And I was expecting something like:
> >
> > DELETE FROM movie LEFT JOIN category WHERE ( category.update_flag = ? ): 'old'
>
> Are you sure that is the right syntax?  The PostgreSQL tutorial
> suggest another form:
>
> DELETE FROM films USING producers
>   WHERE producer_id = producers.id AND producers.name = 'foo';
>
> http://www.postgresql.org/docs/8.3/static/sql-delete.html
>
> Cheers,
> Zbyszek
> http://perlalchemy.blogspot.com
>

Yes, probably that's the right syntax. However I think that mysql also
accepts a join.
But anyway, my point is that DBIC is not doing the right thing here.

Cheers,
-- 
Jonas



More information about the DBIx-Class mailing list