views:

322

answers:

0

I have a Perl DBIx::Class search the looks like this:

my $rs = shift->search( {
      -and => [
            { 'for_revocation' => 1 },
            [
                { 
                     status => { 
                        'not_in' => [ 'revoked', 'revoking'] 
                    },
                },
                {   
                    status => 'revoking',
                    updated => { 
                        '<' => \'now() - interval 1 hour' 
                    }
                },
            ]
        ]
    });

and then I do ..

$rs->update({ status => 'revoked' });

But I get the error ...

DBI Exception: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOR REVOCATION '1' )' at line 1 [for Statement "UPDATE wmv_attempt SET status = ? WHERE ( ARRAY(0xadf93a8) FOR REVOCATION ? )" with ParamValues: 0='revoking', 1=1] at (eval 20938) line 1

If I use $rs->as_query() to get the SQL used to do the search it looks like this:

SELECT .... FROM wmv_attempt me WHERE ( ( ( status NOT IN ( ?, ? ) OR ( status = ? AND 
updated < now() - interval 1 hour ) ) AND for_revocation = ? ) )

Which works fine.

It seems that when it does the update() on the resultset it fails to be able to create the WHERE clause correctly.

I suspect this is a bug.

Can anyone suggest something I might be doing wrong or an alternative approach?

Thanks, Tom