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

Smart Group errors with "Operand should contain 1 column(s)"

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 4.6.7
    • Fix Version/s: None
    • Component/s: Core CiviCRM
    • Labels:
      None
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      For some smart groups, the sql being generated to get the people in the group has two issues. One is malformed and the other might be a bug or oddity with mysql with extra parentheses on the in clauses. Update smart group counts also fail with same error and sql.

      The sql being generated is long and complicated (included at the end of this bug). I was able to simplify it greatly and still get it to error. The following errors with "the operand should contain 1 column(s)"

      SELECT id
      FROM civicrm_group_contact
      WHERE group_id IN ( (6,7,8,11) )

      Remove the extra ( ) and it works.
      Mysql version 5.5.43-0ubuntu0.14.04.1

      The other malformed sql doesn't error but I think also doesn't do what is intended.

      `civicrm_group_contact_cache_(6,7,8,11)`.group_id IN ("(6", "7", "8", "11)")

      It's not going to find the first and last group_id since they have an extra parens included within the quotes.

      Here is the complete sql:

      CREATE TEMPORARY TABLE civicrm_temp_group_contact_cache1864
      (SELECT 20 as group_id,
      contact_a.id as id
      FROM civicrm_contact contact_a LEFT JOIN
      civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) LEFT JOIN
      civicrm_group_contact `civicrm_group_contact-(6,7,8,11)` ON
      (contact_a.id = `civicrm_group_contact-(6,7,8,11)`.contact_id AND `civicrm_group_contact-(6,7,8,11)`.status IN ("Added")) LEFT JOIN
      civicrm_group_contact_cache `civicrm_group_contact_cache_(6,7,8,11)` ON
      contact_a.id = `civicrm_group_contact_cache_(6,7,8,11)`.contact_id
      WHERE ( ( (
      ( `civicrm_group_contact-(6,7,8,11)`.group_id IN ( (6,7,8,11) ) )
      OR ( `civicrm_group_contact_cache_(6,7,8,11)`.group_id IN ("(6", "7", "8", "11)") ) )
      AND contact_a.do_not_mail != 1
      AND civicrm_address.street_address IS NOT NULL
      AND contact_a.contact_type = 'individual' )
      OR ( (
      ( `civicrm_group_contact-(6,7,8,11)`.group_id IN ( (6,7,8,11) ) )
      OR ( `civicrm_group_contact_cache_(6,7,8,11)`.group_id IN ("(6", "7", "8", "11)") ) )
      AND contact_a.do_not_mail != 1
      AND civicrm_address.street_address IS NOT NULL
      AND contact_a.contact_type = 'household' ) )
      AND (contact_a.is_deleted = 0)
      AND contact_a.id NOT IN
      ( SELECT contact_id
      FROM civicrm_group_contact
      WHERE civicrm_group_contact.status = 'Removed'
      AND civicrm_group_contact.group_id = 20 ) )

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Paul-Tahoe Paul Hugo
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: