I have a Perl DBIx :: Class search as follows:
my $rs = shift->search( { -and => [ { 'for_revocation' => 1 }, [ { status => { 'not_in' => [ 'revoked', 'revoking'] }, }, { status => 'revoking', updated => { '<' => \'now() - interval 1 hour' } }, ] ] });
and then I ...
$rs->update({ status => 'revoked' });
But I get an error ...
DBI Exception: DBD :: mysql :: st execute failed: you have an error in your SQL syntax; check the manual that matches your MySQL server version for the correct syntax to use near 'FOR REVOCATION' 1 ')' on line 1 [for Statement "UPDATE wmv_attempt SET status =? WHERE (MASS (0xadf93a8) FOR REVOLUTION?)" 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 great.
It appears that when he does update() on the result set, he cannot correctly create the WHERE clause.
I suspect this is a mistake.
Can anyone suggest something that I might do wrong or an alternative approach?
Thanks Tom
source share