Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-21159

Address fields cause DB errors when adding contacts to group from Search Builder

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Important
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7.21, 4.7.22, 4.7.23, 4.7.27
    • Fix Version/s: 4.7.31
    • Component/s: CiviCRM Search
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code
    • Verified?:
      No

      Description

      "Unknown column" errors occur when the Search Builder is used to create a search that includes an address field (City, State and Country tested so far) from a location type other than Primary, then attempts to add all search results to a group.

      Steps to reproduce:

      1. Create a search using the Search Builder on a CiviCRM 4.7.x site.
      2. Include a State, City, or Country field in the search.
      3. Set the Location Type for that field to anything other than Primary (Home, Billing, Main, Other or Work)
      4. Select all records returned by the search.
      5. Choose "Group - add contacts" from the Actions menu.

      The debug_info from an example of such an error:

      SELECT contact_a.id as contact_id FROM civicrm_contact contact_a WHERE ( ( `Home-address`.state_province_id = '1031' ) ) AND (contact_a.is_deleted = 0) ORDER BY `contact_a`.`sort_name` asc, `contact_a`.`id` [nativecode=1054 ** Unknown column 'Home-address.state_province_id' in 'where clause']
      

      The error doesn't occur if Primary is used as the Location Type, or if the user selects all records displayed on one page of results (no matter how many rows are included) rather than selecting all records.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jackaponte Jack Aponte
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: