X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FImport%2FDataSource%2FSQL.php;h=78b20839f9be3f4bb87f7a2799c143d1076af521;hb=e6229d5aa0bca599fe85ca0a624d86ad14cfb8e1;hp=cfd3c6f727ba93619080c1298745d410768d50eb;hpb=20a7f6d634240ae02d2c9ef3e7263edd4f2fa461;p=civicrm-core.git diff --git a/CRM/Import/DataSource/SQL.php b/CRM/Import/DataSource/SQL.php index cfd3c6f727..78b20839f9 100644 --- a/CRM/Import/DataSource/SQL.php +++ b/CRM/Import/DataSource/SQL.php @@ -92,7 +92,17 @@ class CRM_Import_DataSource_SQL extends CRM_Import_DataSource { $columnNames = []; while ($columnsResult->fetch()) { - $columnNames[] = $columnsResult->Field; + if (strpos($columnsResult->Field, ' ') !== FALSE) { + // Remove spaces as the Database object does this + // $keys = str_replace(array(".", " "), "_", array_keys($array)); + // https://lab.civicrm.org/dev/core/-/issues/1337 + $usableColumnName = str_replace(' ', '_', $columnsResult->Field); + CRM_Core_DAO::executeQuery('ALTER TABLE ' . $tableName . ' CHANGE `' . $columnsResult->Field . '` ' . $usableColumnName . ' ' . $columnsResult->Type); + $columnNames[] = $usableColumnName; + } + else { + $columnNames[] = $columnsResult->Field; + } } $this->addTrackingFieldsToTable($tableName);