Uploaded image for project: 'Reporting Module'
  1. Reporting Module
  2. REPORT-704

Bug in HqlQueryBuilder for non-trivial select clauses

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: TBD
    • Resolution: Fixed
    • Affects Version/s: Reporting 0.9.3
    • Fix Version/s: Reporting 0.9.3
    • Component/s: None
    • Labels:
    • Complexity:
      Undetermined

      Description

      This is a regression caused by this not-yet-released commit: https://github.com/openmrs/openmrs-module-reporting/commit/2068230e6cb89cee954d478344354d25521085b0

      The following unit test demonstrates the issue:

      public class HqlQueryBuilderTest extends BaseModuleContextSensitiveTest {
      ...
          @Test
          public void testAliasRegression() throws Exception {
              HqlQueryBuilder query = new HqlQueryBuilder();
              query.select("a.patientId", "case a.patientId when 1 then true else false end");
              query.from(Patient.class, "a");
              evaluationService.evaluateToMap(query, Integer.class, Boolean.class, new EvaluationContext());
          }
      }
      

      The problem is that given this string "case a.patientId when 1 then true else false end" the code treats things after the last . as the column name, which in this case incorrectly turns out to be "patientId when 1 then true else false end"

      So you end up with "..., case a.patientId when 1 then true else false end as patientId when 1 then true else false end"

        Attachments

          Activity

            People

            Assignee:
            darius Darius Jazayeri [X] (Inactive)
            Reporter:
            darius Darius Jazayeri [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: