CRM-7972 Database Error: Identifier name is too long while importing contacts

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 3.4.0
    • Fix Version/s: Unscheduled
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      While importing contacts from a csv file I get the following Database error message:

      DB Error: a515ac9c2796ca0e23adbe92c68fc9fc
      Error Details
      Database Error Code: Identifier name 'receipt_datefrnamnefternamnnotetransaction_idemail_match_to_contacttilltotal_amountavgiftfeenet_amou' is too long, 1059
      Additional Details:

      Array
      (
      [callback] => Array
      (
      [0] => CRM_Core_Error
      [1] => handle
      )

      [code] => a515ac9c2796ca0e23adbe92c68fc9fc
      [message] => DB Error: a515ac9c2796ca0e23adbe92c68fc9fc
      [mode] => 16
      [debug_info] => CREATE TABLE civicrm_import_job_6a841fd43c5aed055c84f37c7e928500 (`receipt_datefrnamnefternamnnotetransaction_idemail_match_to_contacttilltotal_amountavgiftfeenet_amountsaldocurrencyegen_referensbeskrivningcontribution_typecontribution_sourcepayment_instrumentreceive_datecontribution_statusthank_you_send` text) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci [nativecode=1059 ** Identifier name 'receipt_datefrnamnefternamnnotetransaction_idemail_match_to_contacttilltotal_amountavgiftfeenet_amou' is too long]
      [type] => DB_Error
      [user_info] => CREATE TABLE civicrm_import_job_6a841fd43c5aed055c84f37c7e928500 (`receipt_datefrnamnefternamnnotetransaction_idemail_match_to_contacttilltotal_amountavgiftfeenet_amountsaldocurrencyegen_referensbeskrivningcontribution_typecontribution_sourcepayment_instrumentreceive_datecontribution_statusthank_you_send` text) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci [nativecode=1059 ** Identifier name 'receipt_datefrnamnefternamnnotetransaction_idemail_match_to_contacttilltotal_amountavgiftfeenet_amou' is too long]
      [to_string] => [db_error: message="DB Error: a515ac9c2796ca0e23adbe92c68fc9fc" code=0 mode=callback callback=CRM_Core_Error::handle prefix="" info="CREATE TABLE civicrm_import_job_6a841fd43c5aed055c84f37c7e928500 (`receipt_datefrnamnefternamnnotetransaction_idemail_match_to_contacttilltotal_amountavgiftfeenet_amountsaldocurrencyegen_referensbeskrivningcontribution_typecontribution_sourcepayment_instrumentreceive_datecontribution_statusthank_you_send` text) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci [nativecode=1059 ** Identifier name 'receipt_datefrnamnefternamnnotetransaction_idemail_match_to_contacttilltotal_amountavgiftfeenet_amou' is too long]"]
      )

      The header line of the csv file is:
      "Receipt date";"Förnamn";"Efternamn";"Note";"Transaction ID";"Email (match to contact)";"Till";"total amount";"avgift";"fee";"net amount";"Saldo";"currency";"Egen Referens";"Beskrivning";"Contribution type";"contribution source";"Payment instrument";"Receive Date";"Contribution Status";"Thank you send"

        Attachments

          Activity

          [CRM-7972] Database Error: Identifier name is too long while importing contacts
          Holger Motzkau added a comment -

          I found the reason, the csv was accidentially not comma-seperated. However, the same error occurs if the name of the column/title is longer than 64? characters. I suggest an additional tuncation on the colunm names to 60 characters in CRM_Import_DataSource_CSV.php:116 after $columns = preg_replace('/[^a-z_]/', '', $columns); If dublicate names arise they will be fixed later with $colKey. In case of a wrong csv seperator this will at least lead to an ugly preview of the imported data instead of an ugly mysql error message.

          Donald A. Lobo added a comment -


          Would be great if you can investigate and submit a patch (in which case we'll pull it into an earlier release)

          Holger Motzkau added a comment -

          This patch should do the job.
          Excellent would be an additonal
          if(count($columns)== 1) {
          // print some warning message that the column seperator should be $config->fieldSeparator
          }
          but I don't find a civiCRM function corresponding to drupal_set_message.

          Donald A. Lobo added a comment -


          Closing issues in batch on 4/16/13 since these issues have not been worked on in a long long time

            People

            • Assignee:
              Donald A. Lobo
              Reporter:
              Holger Motzkau

              Dates

              • Created:
                Updated:
                Resolved: