[rt-devel] Limit with IN operator and empty VALUES results in invalid SQL queries

Alex Vandiver alexmv at bestpractical.com
Wed Dec 10 13:49:22 EST 2014

On 12/10/2014 04:46 AM, Christian Loos wrote:
>> yesterday I saw some invalid MySQL queries in my logs:
>> [snip]
> I changed
> $self->Limit( FIELD => 'Id', OPERATOR => 'IN', VALUE => \@match );
> to
> $self->Limit( FIELD => 'Id', OPERATOR => 'IN', VALUE => @match ? \@match
> : [0] );
> which fixes the bug for me.
> It would be great if one of the developers can review this and give some
> feedback.

Sorry -- this was flagged on my "should look at" but I'd not gotten to
it.  I've pushed 4.2/empty-in-clause with a similar-looking change.

> I'm not sure if this should only be fixed in RT or if this should be
> fixed in DBIx::SearchBuilder (always generate valid SQL even if the
> provided VALUE is an empty list).

It's hard to decide if DBIx::SearchBuilder should apply no limit, or
apply a never-match limit in such cases.  RT has cases of each.
 - Alex

More information about the rt-devel mailing list