Re: Limit with IN operator and empty VALUES results in invalid SQL queries

Christian Loos <[email protected]> Thu, 11 Dec 2014 16:02:50 +0100
Newsgroups gmane.comp.bug-tracking.request-tracker.devel
Message-ID <[email protected]>
Am 10.12.2014 um 19:49 schrieb Alex Vandiver:
> 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 applied you change for RT::Report::Tickets on my 4.2.9 and the hundred
of error messages are gone. Thanks.

> 
>> 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.