Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5430

Form Search Criteria doesn't work as expected

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Platform 2.2.0
    • Component/s: None
    • Labels:
      None
    • Complexity:
      Low

      Description

      The getFormCriteria() method doesn't actually filter out forms rightly with the _ containingAllFormFields_ argument.

      I hit upon this bug while working on TRUNK-5307.
      Test Case

      @Test
      public void shouldFilterAgainstAllFormFields() {
      	
      	// Existing formFields but but no Form has them all
      	List<FormField> formFields = Arrays.asList(new FormField(2), new FormField(3), new FormField(5), new FormField(6));
      		
      	Assert.assertEquals(0, (Object)dao.getForms(null, false, Collections.emptyList(), null, Collections.emptyList(), formFields, Collections.emptyList()).size()); //Returns all forms which is wrong
      		
      }
      

      Dataset: https://gist.github.com/samuelmale/b0f8eac887de2ca8f641d1456817785c

      With deeper trouble shooting, with the above testcase, Hibernate produces sql string below

      select this_.form_id as form_id1_40_0_, this_.uuid as uuid2_40_0_, this_.name as name3_40_0_, this_.version as version4_40_0_, this_.build as build5_40_0_, this_.published as publishe6_40_0_, this_.description as descript7_40_0_, this_.encounter_type as encounte8_40_0_, this_.creator as creator9_40_0_, this_.date_created as date_cr10_40_0_, this_.changed_by as changed11_40_0_, this_.date_changed as date_ch12_40_0_, this_.retired as retired13_40_0_, this_.retired_by as retired14_40_0_, this_.date_retired as date_re15_40_0_, this_.retired_reason as retired16_40_0_ from form this_ where this_.published=? and ? = (select count(ff_.form_field_id) as y0_ from form_field ff_ where ff_.form_id=ff_.form_id and ff_.form_field_id in (?, ?, ?, ?))
      
      

        Attachments

          Activity

            People

            Assignee:
            samuel34 Samuel Male
            Reporter:
            samuel34 Samuel Male
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: