
falcone at bestpractical
Jan 19, 2012, 3:57 PM
Post #1 of 1
(60 views)
Permalink
|
|
rt branch, 4.0/bookmark-ticketsql-ordering, created. rt-4.0.4-216-g9d3a627
|
|
The branch, 4.0/bookmark-ticketsql-ordering has been created at 9d3a6272fbfe0c366c63bfebcf593aff24035fae (commit) - Log ----------------------------------------------------------------- commit 842a80de83633ee32fe1876b2368776759e429b8 Author: Kevin Falcone <falcone [at] bestpractical> Date: Thu Jan 19 18:51:28 2012 -0500 Incorrect SQL if id = '__Bookmarked__' isn't first in a search The ENTRYAGGREGATOR ends up set to AND so we search for id = 3 AND id = 4 diff --git a/t/api/bookmarks.t b/t/api/bookmarks.t new file mode 100644 index 0000000..138fd49 --- /dev/null +++ b/t/api/bookmarks.t @@ -0,0 +1,20 @@ +use strict; +use warnings; +use RT::Test tests => 32; + +my ( $url, $m ) = RT::Test->started_ok; +my $root = RT::Test->load_or_create_user( Name => 'root' ); + +my @tickets = RT::Test->create_tickets( { }, map { { Subject => "Test $_" } } ( 1 .. 9 ) ); + +# 4.2 gives us $user->ToggleBookmark which is nicer +$root->SetAttribute( Name => 'Bookmarks', Content => { map { $_ => 1 } (3,6,9) } ); + +my $cu = RT::CurrentUser->new($root); +my $bookmarks = RT::Tickets->new($cu); +for my $search ( "Queue = 'General' AND id = '__Bookmarked__'", + "id = '__Bookmarked__' AND Queue = 'General'" ) { + $bookmarks->FromSQL($search); + #diag $bookmarks->BuildSelectQuery; + is($bookmarks->Count,3,"Found my 3 bookmarks for [$search]"); +} commit 9d3a6272fbfe0c366c63bfebcf593aff24035fae Author: Kevin Falcone <falcone [at] bestpractical> Date: Thu Jan 19 18:52:13 2012 -0500 Only pass in context on the first iteration Otherwise we pick up the AND from the surrounding context rather than the OR that we calculated a few lines earlier and should be using. See #19267 for more information. diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm index ec78efd..7ed43f7 100644 --- a/lib/RT/Tickets.pm +++ b/lib/RT/Tickets.pm @@ -337,6 +337,7 @@ sub _BookmarkLimit { VALUE => $id, $first? (@rest): ( ENTRYAGGREGATOR => $ea ) ); + $first = 0 if $first; } $sb->_CloseParen; } ----------------------------------------------------------------------- _______________________________________________ Rt-commit mailing list Rt-commit [at] lists http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit
|