Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-77555

Report builder filters break with params

XMLWordPrintable

      1. In code, define a filter which uses at least one parameter
      2. Set the filter class to \core_reportbuilder\local\filters\number
      3. Create a report that includes this filter
      4. Try to filter by a range of values (or empty / not empty)

      Expected result:

      • Filter is applied without problems

      Actual result:

      • Error - ERROR: Incorrect number of query parameters. Expected 4, got 3

      (This 'date' filter class is also affected).

      Reason - these filter classes duplicate the SQL for the filter, leaving any embedded params unmodified, e.g. if the SQL was:

      (SELECT COUNT(1) FROM {x} WHERE {x}.timedue > :rbparam1)
      

      With params: ['rbparam1' => time()]

      The final SQL generated is:

      (SELECT COUNT(1) FROM {x} WHERE {x}.timedue > :rbparam1) >= :rbparam2 AND (SELECT COUNT(1) FROM {x} WHERE {x}.timedue > :rbparam1) <= :rbparam3
      

      With params ['rbparam1' => time(), 'rbparam2' => 'value entered in filter form', 'rbparam3' => 'value entered in filter form]

            pholden Paul Holden
            davosmith Davo Smith
            Carlos Castillo Carlos Castillo
            David Carrillo David Carrillo
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 3 hours, 15 minutes
                1d 3h 15m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.