5.51 import error when CSV header contains spaces in column names
My client attempted to import a CSV with this as the header row:
ID,IND/ORG,SALUTATION,FIRSTNAME,LASTNAME,Status,Country,EMAILADDRESS,AGBUHIGHLIGHTSRECIPIENT,AGBUARMENIA,YOUNGPROFESSIONALS,Do Not Mail,Valid Address
That yielded this error/backtrace, which seems connected to the field names. Note that I looked at civicrm_tmp_d_dflt_53f990c8f2166dca1b59a22af4096233
and the column names were snake-cased (e.g. do_not_mail
).
[error] $Fatal Error Details = Array
(
[callback] => Array
(
[0] => CRM_Core_Error
[1] => exceptionHandler
)
[code] => -2
[message] => DB Error: syntax error
[mode] => 16
[debug_info] => SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, Status, Country, EMAILADDRESS, AGBUHIGHLIGHTSRECIPIENT, AGBUARMENIA, YOUNGPROFESSIONALS, Do Not Mail, Valid Address FROM civicrm_tmp_d_dflt_53f990c8f2166dca1b59a22af4096233 WHERE _status IN ("error","invalid","soft_credit_error","pledge_payment_error") [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Mail, Valid Address FROM civicrm_tmp_d_dflt_53f990c8f2166dca1b59a22af4096233 ...' at line 1]
[type] => DB_Error
[user_info] => SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, Status, Country, EMAILADDRESS, AGBUHIGHLIGHTSRECIPIENT, AGBUARMENIA, YOUNGPROFESSIONALS, Do Not Mail, Valid Address FROM civicrm_tmp_d_dflt_53f990c8f2166dca1b59a22af4096233 WHERE _status IN ("error","invalid","soft_credit_error","pledge_payment_error") [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Mail, Valid Address FROM civicrm_tmp_d_dflt_53f990c8f2166dca1b59a22af4096233 ...' at line 1]
[to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, Status, Country, EMAILADDRESS, AGBUHIGHLIGHTSRECIPIENT, AGBUARMENIA, YOUNGPROFESSIONALS, Do Not Mail, Valid Address FROM civicrm_tmp_d_dflt_53f990c8f2166dca1b59a22af4096233 WHERE _status IN ("error","invalid","soft_credit_error","pledge_payment_error") [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Mail, Valid Address FROM civicrm_tmp_d_dflt_53f990c8f2166dca1b59a22af4096233 ...' at line 1]"]
)
[debug] $backTrace = #0 /code/vendor/civicrm/civicrm-core/CRM/Core/Error.php(954): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /code/vendor/pear/pear-core-minimal/src/PEAR.php(944): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#2 /code/vendor/pear/db/DB.php(997): PEAR_Error->__construct("DB Error: syntax error", -2, 16, (Array:2), "SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, S...")
#3 /code/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-2, 16, (Array:2), "SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, S...")
#4 /code/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR::_raiseError(Object(DB_mysqli), NULL, -2, 16, (Array:2), "SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, S...", "DB_Error", TRUE)
#5 /code/vendor/pear/db/DB/common.php(1928): PEAR->__call("raiseError", (Array:7))
#6 /code/vendor/pear/db/DB/mysqli.php(936): DB_common->raiseError(-2, NULL, NULL, "SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, S...", "1064 ** You have an error in your SQL syntax; check the manual that correspon...")
#7 /code/vendor/pear/db/DB/mysqli.php(406): DB_mysqli->mysqliRaiseError()
#8 /code/vendor/pear/db/DB/common.php(1234): DB_mysqli->simpleQuery("SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, S...")
#9 /code/vendor/civicrm/civicrm-packages/DB/DataObject.php(2696): DB_common->query("SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, S...")
#10 /code/vendor/civicrm/civicrm-packages/DB/DataObject.php(1829): DB_DataObject->_query("SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, S...")
#11 /code/vendor/civicrm/civicrm-core/CRM/Core/DAO.php(472): DB_DataObject->query("SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, S...")
#12 /code/vendor/civicrm/civicrm-core/CRM/Core/DAO.php(1637): CRM_Core_DAO->query("SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, S...", TRUE)
#13 /code/vendor/civicrm/civicrm-core/CRM/Import/DataSource.php(568): CRM_Core_DAO::executeQuery("SELECT _id, _status_message, ID, IND/ORG, SALUTATION, FIRSTNAME, LASTNAME, S...")
#14 /code/vendor/civicrm/civicrm-core/CRM/Import/DataSource.php(229): CRM_Import_DataSource->instantiateQueryObject()
#15 /code/vendor/civicrm/civicrm-core/CRM/Import/DataSource.php(212): CRM_Import_DataSource->getRow()
#16 /code/vendor/civicrm/civicrm-core/CRM/Import/Forms.php(473): CRM_Import_DataSource->getRows()
#17 /code/vendor/civicrm/civicrm-core/CRM/Import/Forms.php(528): CRM_Import_Forms->getOutputRows((Array:1))
#18 /code/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php(285): CRM_Import_Forms::outputCSV()
#19 /code/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem((Array:17))
#20 /code/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:3))
#21 /code/modules/contrib/civicrm/src/Civicrm.php(88): CRM_Core_Invoke::invoke((Array:3))
#22 /code/modules/contrib/civicrm/src/Controller/CivicrmController.php(80): Drupal\civicrm\Civicrm->invoke((Array:3))
#23 [internal function](): Drupal\civicrm\Controller\CivicrmController->main((Array:3), "")
#24 /code/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array((Array:2), (Array:2))
#25 /code/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#26 /code/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#27 /code/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext((Array:2), (Array:2))
#28 /code/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#29 /code/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#30 /code/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
#31 /code/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
#32 /code/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
#33 /code/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
#34 /code/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
#35 /code/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
#36 /code/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
#37 /code/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
#38 /code/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#39 {main}