CRM-19910 Drupal view contact sub type IN query

    Details

    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Core Team Funds
    • Verified?:
      No

      Description

      In Drupal view when we using filter for contact sub type,
      query is being built as "WHERE (( (civicrm_contact.contact_sub_type IN ('Student')) ))"

      but in database contact sub type is stored with CiviCRM separator.
      so when contact having more than one role this query is not working as expected.

        Attachments

          Activity

          [CRM-19910] Drupal view contact sub type IN query
          Jitendra Purohit added a comment - - edited

          Though I'm able to see the query being built as shown, it seems to be handled and works for me as expected. See screenshot.

          Can you provide a little more information on this? Is there any error you see on view? Or some contacts do get included/excluded fom the result?

          Thanks.

          Vakees K added a comment -

          when you add more than one role for single contact, then you can see the different.

          Kurund Jalmi added a comment -

          Please considering funding to fix this issue (Paid issue: https://civicrm.org/paid-issue-queue) if it's critical for your organization. Estimate: 2-3 hours.

          Jitendra Purohit added a comment -

          Submitted a PR - https://github.com/civicrm/civicrm-drupal/pull/424. Vakees K Can you check if it is working fine for you?

          Vakees K added a comment -

          Tested. it is working OK, Thank you.

          Joanne Chester added a comment -

          I am not sure, but I think that this patch has broken the situation where the contact has only one sub-type.

          We have a view that only designed to work when contact sub-type is Group.  

          It has been working in 4.4 without any problems for the view set up as "Subtype is one of 'Group" where the query includes: AND (civicrm_contact.contact_sub_type IN ('Group')) AND"

          It also works if I set the view up as  "Subtype is not one of ''Paid_staff', 'Health_Professional',..."  where the query includes:  AND (civicrm_contact.contact_sub_type NOT IN ('Paid_staff', 'Health_Professional', ...)) AND

          We are upgrading to 4.7.17 and testing has shown that view no longer works when it is set up with "Subtype is one of 'Group" where the query now includes:  *AND (civicrm_contact.contact_sub_type LIKE '%Group%' ) AND*

          However it will still work  if I set the view up as "Subtype is not one of ''Paid_staff', 'Health_Professional',..."  where the query now includes:

          *AND (civicrm_contact.contact_sub_type NOT LIKE '%Paid_staff%' AND civicrm_contact.contact_sub_type NOT LIKE '%Health_Professional%' ... ) AND*

           I can't be sure that the patch in this issue has caused the regression, but it seems highly likely.

          Jitendra Purohit added a comment - - edited

          Joanne Chester This is done as per the execution in core CiviCRM. If you enter a single contact subtype (say Group) in Advanced Search or Basic Search - it results all the contacts that contain `Group` as a subtype. So to keep behavior consistent, this ticket modifies the query to result in the same way.

          To get the single contact subtype result, workaround could be to check all other subtypes with "is not one of" operator as described by you in the above comment.

            People

            • Assignee:
              Jitendra Purohit
              Reporter:
              Vakees K

              Dates

              • Created:
                Updated: