diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm index 73a51b38d23..1920ef90ab6 100644 --- a/lib/RT/Interface/Web.pm +++ b/lib/RT/Interface/Web.pm @@ -5810,11 +5810,16 @@ sub PreprocessTransactionSearchQuery { my @limits; if ( $args{ObjectType} eq 'RT::Ticket' ) { - @limits = ( - q{TicketType = 'ticket'}, - qq{ObjectType = '$args{ObjectType}'}, - $args{Query} =~ /^\s*\(.*\)$/ ? $args{Query} : "($args{Query})" - ); + if ( $args{Query} !~ /^TicketType = 'ticket' AND ObjectType = '$args{ObjectType}' AND (.+)/ ) { + @limits = ( + q{TicketType = 'ticket'}, + qq{ObjectType = '$args{ObjectType}'}, + $args{Query} =~ /^\s*\(.*\)$/ ? $args{Query} : "($args{Query})" + ); + } + else { + @limits = $args{Query}; + } } else { # Other ObjectTypes are not supported for now diff --git a/lib/RT/Interface/Web/QueryBuilder/Tree.pm b/lib/RT/Interface/Web/QueryBuilder/Tree.pm index 59365881da9..2b1f8cb5c12 100644 --- a/lib/RT/Interface/Web/QueryBuilder/Tree.pm +++ b/lib/RT/Interface/Web/QueryBuilder/Tree.pm @@ -297,7 +297,8 @@ sub __LinearizeTree { $str .= $key ." ". $op . " " . $value; } - $str =~ s/^\s+|\s+$//; + $str =~ s/^\s+//; + $str =~ s/\s+$//; push @$list, { NODE => $node, diff --git a/t/web/search_txns.t b/t/web/search_txns.t index bf4ca0b817f..24366e19117 100644 --- a/t/web/search_txns.t +++ b/t/web/search_txns.t @@ -29,9 +29,14 @@ diag "Query builder"; $m->follow_link_ok( { id => 'page-results' } ); $m->title_is('Found 3 transactions'); + $m->get_ok($m->uri . '&RowsPerPage=1'); + $m->follow_link_ok( { text => '2' } ); + $m->follow_link_ok( { text => '3' } ); + + $m->follow_link_ok( { text => 'Edit Search' }, 'Build Query' ); + my $form = $m->form_name('BuildQuery'); + is($form->find_input('Query')->value, qq{TicketType = 'ticket' AND ObjectType = 'RT::Ticket' AND ( TicketId = 1 )}); - $m->back; - $m->form_name('BuildQuery'); $m->field( TypeOp => '=' ); $m->field( ValueOfType => 'Create' ); $m->click('AddClause');