[Rt-commit] rt branch 5.0/fix-bind-variables-in-chart-query created. rt-5.0.2-38-g314d4c4609

BPS Git Server git at git.bestpractical.com
Thu Dec 2 21:36:22 UTC 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/fix-bind-variables-in-chart-query has been created
        at  314d4c46091c4c6bf2f940bfa64d6746923fc658 (commit)

- Log -----------------------------------------------------------------
commit 314d4c46091c4c6bf2f940bfa64d6746923fc658
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Dec 3 05:21:26 2021 +0800

    Add chart tests for queries with JOINs
    
    This is initially to make sure bind variables work as expected when
    subqueries are involved, see also 8c29fd6cc3.

diff --git a/t/web/charting.t b/t/web/charting.t
index 7049a82137..bb7ecb87b2 100644
--- a/t/web/charting.t
+++ b/t/web/charting.t
@@ -94,4 +94,14 @@ like( $advanced, qr{Query=id%3E0},
       'Advanced link still has Query param with id search'
     );
 
+# Test query with JOINs
+$m->get_ok( "/Search/Chart.html?Query=Requestor.Name LIKE 'root'" );
+$m->content_like(qr{<th[^>]*>Status\s*</th>\s*<th[^>]*>Ticket count\s*</th>}, "Grouped by status");
+$m->content_like(qr{new\s*</th>\s*<td[^>]*>\s*<a[^>]*>7</a>}, "Found results in table");
+$m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
+
+$m->get_ok( "/Search/Chart?Query=Requestor.Name LIKE 'root'" );
+is( $m->content_type, "image/png" );
+ok( length($m->content), "Has content" );
+
 done_testing;

commit dd317050cbab9bc91d8530e2187429401f16b802
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Dec 3 04:58:20 2021 +0800

    Do not use bind variables in intermediate subqueries
    
    The whole query will be optimized with bind variables in the final step,
    and all bind values added in subquries will be dropped and could cause
    the following error if there were any:
    
        execute called with an unbound placeholder

diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index abed846426..6b028bc653 100644
--- a/lib/RT/Report/Tickets.pm
+++ b/lib/RT/Report/Tickets.pm
@@ -670,7 +670,7 @@ sub SetupGroupings {
         # within the matching tickets grouped by what is wanted.
         $self->Columns( 'id' );
         if ( RT->Config->Get('UseSQLForACLChecks') ) {
-            my $query = $self->BuildSelectQuery;
+            my $query = $self->BuildSelectQuery( PreferBind => 0 );
             $self->CleanSlate;
             $self->Limit( FIELD => 'Id', OPERATOR => 'IN', VALUE => "($query)", QUOTEVALUE => 0 );
         }

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list