开发者

Why does Perl's DBIx::Class $resultset->update fail on complex search queries? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

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 som开发者_JAVA技巧ething I might be doing wrong or an alternative approach?

Thanks, Tom

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜