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

Custom field in duplicate matching causes SQL error on some imports

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.4
    • Component/s: None
    • Labels:
      None

      Description

      With a duplicate matching rule of:

      first name AND last name AND email AND custom_18

      and mapping a column of an import file to custom_18 (actually its name equivalent, like "SOS ID"), the import process will throw up a core MySQL error in the last stage of import (see text below).

      Removing custom_18 from the duplicate matching rule prevents this bug from occurring. Never mapping a column to custom_18 during import also prevents the bug but then you wouldn't be matching anything anyway.

      Bug replicated on CiviCRM.org's demo install and my copy of 1.4 rev 5295M on PHP5 MySQL 4.1. Ask jesse@idcwebdev.com for the file I've been testing this with if necessary.

      [debug_info] => SELECT DISTINCT civicrm_contact.id as id FROM civicrm_contact LEFT JOIN civicrm_individual ON (civicrm_contact.id = civicrm_individual.contact_id) LEFT JOIN civicrm_location ON (civicrm_location.entity_table = 'civicrm_contact' AND
      civicrm_contact.id = civicrm_location.entity_id AND civicrm_location.is_primary = 1) LEFT JOIN civicrm_address ON civicrm_location.id = civicrm_address.location_id LEFT JOIN civicrm_email ON (civicrm_location.id = civicrm_email.location_id AND civicrm_email.is_primary = 1)
      LEFT JOIN civicrm_custom_value custom_value_18 ON custom_value_18.custom_field_id = 18 AND custom_value_18.entity_table = 'civicrm_contact' AND custom_value_18.entity_id = civicrm_contact.id WHERE civicrm_contact.domain_id = 1 AND civicrm_contact.contact_type IN ('Individual') AND LOWER(civicrm_individual.first_name) = "chong" AND LOWER(civicrm_individual.last_name) = "xiong" AND custom_value_18.int_data = [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3]
      [type] => DB_Error
      [user_info] => SELECT DISTINCT civicrm_contact.id as id FROM civicrm_contact LEFT JOIN civicrm_individual ON (civicrm_contact.id = civicrm_individual.contact_id) LEFT JOIN civicrm_location ON (civicrm_location.entity_table = 'civicrm_contact' AND
      civicrm_contact.id = civicrm_location.entity_id AND civicrm_location.is_primary = 1) LEFT JOIN civicrm_address ON civicrm_location.id = civicrm_address.location_id LEFT JOIN civicrm_email ON (civicrm_location.id = civicrm_email.location_id AND civicrm_email.is_primary = 1)
      LEFT JOIN civicrm_custom_value custom_value_18 ON custom_value_18.custom_field_id = 18 AND custom_value_18.entity_table = 'civicrm_contact' AND custom_value_18.entity_id = civicrm_contact.id WHERE civicrm_contact.domain_id = 1 AND civicrm_contact.contact_type IN ('Individual') AND LOWER(civicrm_individual.first_name) = "chong" AND LOWER(civicrm_individual.last_name) = "xiong" AND custom_value_18.int_data = [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3]
      [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT DISTINCT civicrm_contact.id as id FROM civicrm_contact LEFT JOIN civicrm_individual ON (civicrm_contact.id = civicrm_individual.contact_id) LEFT JOIN civicrm_location ON (civicrm_location.entity_table = 'civicrm_contact' AND
      civicrm_contact.id = civicrm_location.entity_id AND civicrm_location.is_primary = 1) LEFT JOIN civicrm_address ON civicrm_location.id = civicrm_address.location_id LEFT JOIN civicrm_email ON (civicrm_location.id = civicrm_email.location_id AND civicrm_email.is_primary = 1)
      LEFT JOIN civicrm_custom_value custom_value_18 ON custom_value_18.custom_field_id = 18 AND custom_value_18.entity_table = 'civicrm_contact' AND custom_value_18.entity_id = civicrm_contact.id WHERE civicrm_contact.domain_id = 1 AND civicrm_contact.contact_type IN ('Individual') AND LOWER(civicrm_individual.first_name) = "chong" AND LOWER(civicrm_individual.last_name) = "xiong" AND custom_value_18.int_data = [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3]"]

        Attachments

          Activity

            People

            • Assignee:
              kurund Kurund Jalmi
              Reporter:
              jesse_idc Jesse Mortenson
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: