Logic of RT::Tickets::Limit*?

I’m playing with RT::tickets::Limit*, and I’m confuzzled.

If I have:

my $MyTickets;
$MyTickets = new RT::Tickets ($session{‘CurrentUser’});
$MyTickets->LimitOwner(VALUE => “Nobody”);
$MyTickets->LimitStatus(VALUE => “new”);
$MyTickets->LimitStatus(VALUE => “open”);
$MyTickets->LimitStatus(VALUE => “stalled”);
$MyTickets->OrderBy(FIELD => ‘Created’, ORDER => ‘ASC’);
$MyTickets->RowsPerPage(25);

my current data gives me the 9 tickets that this query would give:

select id, Queue, Owner, Subject, Status from Tickets where owner=2
and (status = ‘new’ or status = ‘open’ or status = ‘stalled’);

but if I have:

my $MyTickets;
$MyTickets = new RT::Tickets ($session{‘CurrentUser’});
$MyTickets->LimitOwner(VALUE => “Nobody”);
$MyTickets->OrderBy(FIELD => ‘Created’, ORDER => ‘ASC’);
$MyTickets->RowsPerPage(25);

then I only get 4, even though

select id, Queue, Owner, Subject, Status from Tickets where owner=2;

returns 56 rows, and my DWIM guess of

select id, Queue, Owner, Subject, Status from Tickets where owner=2
and (status != ‘dead’ and status != ‘resolved’);

gives me 9 rows. The four that I do get all have status “new”, and
some of the ones I don’t get back also have status “new”, so it’s
not implicitly limiting status=new.

Interestingly, the four that bit of Perl code returns are the four
oldest tickets in the nine that the SQL query returns.

Similarly, in the Search panel in WebRT, the search

Owner = Nobody

gives me four tickets, and the search

Owner = Nobody
Status = new
Status = open
Status = stalled

gives me nine.

Am I calling on undefined behavior here, or is there some logic that
I’m missing or misunderstanding? My assumption was that multiple
LimitFoo are OR’d, while LimitFoo is AND’d with LimitBar, and thus
that the number of results returned from one LimitOwner call would
have to be equal to or greater than the number of results returned
by a LimitOwner combined with LimitStatus(es).

-Rich

Rich Lafferty --------------±----------------------------------------------
Ottawa, Ontario, Canada | Save the Pacific Northwest Tree Octopus!
http://www.lafferty.ca/ | Save The Pacific Northwest Tree Octopus
rich@lafferty.ca -----------±----------------------------------------------

I’m playing with RT::tickets::Limit*, and I’m confuzzled.

Actually, for each of these perl snippets, could you quote the SQL that it
generates?

Am I calling on undefined behavior here, or is there some logic that
I’m missing or misunderstanding? My assumption was that multiple

Invoke UnLimit() first :wink:

LimitFoo are OR’d, while LimitFoo is AND’d with LimitBar, and thus
that the number of results returned from one LimitOwner call would
have to be equal to or greater than the number of results returned
by a LimitOwner combined with LimitStatus(es).

This is my understanding.

                         Bruce Campbell                            RIPE
               Systems/Network Engineer                             NCC
             www.ripe.net - PGP562C8B1B                      Operations

I’m playing with RT::tickets::Limit*, and I’m confuzzled.

Actually, for each of these perl snippets, could you quote the SQL that it
generates?

I assume that’s easy to pull out – how can I find it to quote it?

Am I calling on undefined behavior here, or is there some logic that
I’m missing or misunderstanding? My assumption was that multiple

Invoke UnLimit() first :wink:

I’m not sure if that was serious or not, but since UnLimit existed,
I tried it, and it didn’t change anything.

Thanks,

-Rich

Rich Lafferty --------------±----------------------------------------------
Ottawa, Ontario, Canada | Save the Pacific Northwest Tree Octopus!
http://www.lafferty.ca/ | Save The Pacific Northwest Tree Octopus
rich@lafferty.ca -----------±----------------------------------------------

I’m playing with RT::tickets::Limit*, and I’m confuzzled.

Actually, for each of these perl snippets, could you quote the SQL that it
generates?

I assume that’s easy to pull out – how can I find it to quote it?

MySQL server logs I’m afraid. If you’re connecting from one definite host
for your tests, you can sift out your specific queries (change
rt2_user@my.host.name as appropriate):

mysqlgrunt$ cat /var/mysql/hostname.log | perl -e '$curnum=undef;
while(<>){ if( defined( $curnum) ){ if( m/\s+$curnum\s+\S+\s+/ ){
print; } }; next unless(
m/\s+(\d+)\s+Connect\s+rt2_user\@my\.host\.name/ ); $curnum=$1;
print;}' | less

Am I calling on undefined behavior here, or is there some logic that
I’m missing or misunderstanding? My assumption was that multiple

Invoke UnLimit() first :wink:

I’m not sure if that was serious or not, but since UnLimit existed,
I tried it, and it didn’t change anything.

No, but it solved a problem for me some months back, always worth
checking, particularly if all of your perl snippets were being executed in
the same context.

                         Bruce Campbell                            RIPE
               Systems/Network Engineer                             NCC
             www.ripe.net - PGP562C8B1B                      Operations

Excitement of the moment - a taxi just tried to argue right of way with a
tram, which came to a sparking halt in the middle of the intersection and
Had Words™.

MySQL server logs I’m afraid.

(I was able to set DBIx::SearchBuilder::DEBUG and get it out that
way.)

Eureka!

The query is

SELECT DISTINCT main.* FROM Tickets main WHERE ((main.EffectiveId = main.id))
AND ((main.Owner = ‘2’)) ORDER BY main.Created ASC LIMIT 25

which returns 25 tickets as expected. But 19 of the 25 have a status
of “dead”. Dead tickets are hidden in RT, not excluded in the query,
so since I’m limiting the results to 25, I’m getting 19 dead tickets
and 4 live ones; when I explicitly ask for new/open/stalled, I’m not
getting the dead tickets so I get all 9 live ones.

I’m inclined to think that that could be done more gracefully,
although my code is content now that I understand why my workaround
works. Jesse, is that Working As Designed or have I found an
unintended side-effect?

-Rich

Rich Lafferty --------------±----------------------------------------------
Ottawa, Ontario, Canada | Save the Pacific Northwest Tree Octopus!
http://www.lafferty.ca/ | Save The Pacific Northwest Tree Octopus
rich@lafferty.ca -----------±----------------------------------------------

I could have sworn that at some point, AND Status != ‘Dead’ got added
to the SQL generation in Tickets.pm.On Tue, May 21, 2002 at 04:10:32PM -0400, Rich Lafferty wrote:

On Tue, May 21, 2002 at 08:42:36PM +0200, Bruce Campbell (bruce_campbell@ripe.net) wrote:

MySQL server logs I’m afraid.

(I was able to set DBIx::SearchBuilder::DEBUG and get it out that
way.)

Eureka!

The query is

SELECT DISTINCT main.* FROM Tickets main WHERE ((main.EffectiveId = main.id))
AND ((main.Owner = ‘2’)) ORDER BY main.Created ASC LIMIT 25

which returns 25 tickets as expected. But 19 of the 25 have a status
of “dead”. Dead tickets are hidden in RT, not excluded in the query,
so since I’m limiting the results to 25, I’m getting 19 dead tickets
and 4 live ones; when I explicitly ask for new/open/stalled, I’m not
getting the dead tickets so I get all 9 live ones.

I’m inclined to think that that could be done more gracefully,
although my code is content now that I understand why my workaround
works. Jesse, is that Working As Designed or have I found an
unintended side-effect?

-Rich


Rich Lafferty --------------±----------------------------------------------
Ottawa, Ontario, Canada | Save the Pacific Northwest Tree Octopus!
http://www.lafferty.ca/ | Save The Pacific Northwest Tree Octopus
rich@lafferty.ca -----------±----------------------------------------------


rt-devel mailing list
rt-devel@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-devel

http://www.bestpractical.com/products/rt – Trouble Ticketing. Free.

I could have sworn that at some point, AND Status != ‘Dead’ got added
to the SQL generation in Tickets.pm.

Well, there’s this:

        #Make sure we _never_ show dead tickets
        #TODO we should be doing this in the where clause.
        #but you can't do multiple clauses on the same field just yet :/

which makes me think you’re remembering 2.1.x, maybe. I went to fix
this but I’m not sure I grok that comment. Can you either tell me
what that means or tell me that I don’t need to know what it means
because you’ll fix it? :slight_smile:

-Rich

Rich Lafferty --------------±----------------------------------------------
Ottawa, Ontario, Canada | Save the Pacific Northwest Tree Octopus!
http://www.lafferty.ca/ | Save The Pacific Northwest Tree Octopus
rich@lafferty.ca -----------±----------------------------------------------