Fatal error in export when using "Merge All Contacts with the Same Address" and Selected Fields instead of Primary Fields
See https://civicrm.stackexchange.com/questions/33272/fatal-error-on-export-in-5-18-1/33273#33273
- Do a contact search.
- Select some results.
- Choose Export from the Actions dropdown.
- Choose Selected Fields.
- Choose the option "Merge All Contacts with the Same Address".
- Pick your selected fields.
- Export.
Db error, because there's an extra comma being added at the end of the field list or possibly a field name is supposed to be there but comes out blank. Then it's followed by a php notice when you go to another page.
Database Error Code: 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 ' PRIMARY KEY ( id ), INDEX index_street_address( street_address ) , INDEX i' at line 15, 1064
Additional Details:
Array
(
[callback] => Array
(
[0] => CRM_Core_Error
[1] => handle
)
[code] => -2
[message] => DB Error: syntax error
[mode] => 16
[debug_info] => CREATE TABLE `civicrm_tmp_d_export_4fa32a2a24bde72ebb683e1e36771419` ( id int unsigned NOT NULL AUTO_INCREMENT, display_name varchar(128),
addressee varchar(255),
postal_greeting varchar(255),
email_greeting varchar(255),
street_name varchar(64),
household_name varchar(128),
street_address varchar(96),
city varchar(64),
state_province varchar(64),
civicrm_primary_id varchar(16),
master_id varchar(128),
state_province_id varchar(255),
postal_greeting_id varchar(16),
addressee_id varchar(16),
,
PRIMARY KEY ( id ),
INDEX index_street_address( street_address )
,
INDEX index_household_name( household_name )
,
INDEX index_civicrm_primary_id( civicrm_primary_id )
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci [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 '
PRIMARY KEY ( id ),
INDEX index_street_address( street_address )
,
INDEX i' at line 15]
[type] => DB_Error
[user_info] => CREATE TABLE `civicrm_tmp_d_export_4fa32a2a24bde72ebb683e1e36771419` ( id int unsigned NOT NULL AUTO_INCREMENT, display_name varchar(128),
addressee varchar(255),
postal_greeting varchar(255),
email_greeting varchar(255),
street_name varchar(64),
household_name varchar(128),
street_address varchar(96),
city varchar(64),
state_province varchar(64),
civicrm_primary_id varchar(16),
master_id varchar(128),
state_province_id varchar(255),
postal_greeting_id varchar(16),
addressee_id varchar(16),
,
PRIMARY KEY ( id ),
INDEX index_street_address( street_address )
,
INDEX index_household_name( household_name )
,
INDEX index_civicrm_primary_id( civicrm_primary_id )
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci [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 '
PRIMARY KEY ( id ),
INDEX index_street_address( street_address )
,
INDEX i' at line 15]
[to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="CREATE TABLE `civicrm_tmp_d_export_4fa32a2a24bde72ebb683e1e36771419` ( id int unsigned NOT NULL AUTO_INCREMENT, display_name varchar(128),
addressee varchar(255),
postal_greeting varchar(255),
email_greeting varchar(255),
street_name varchar(64),
household_name varchar(128),
street_address varchar(96),
city varchar(64),
state_province varchar(64),
civicrm_primary_id varchar(16),
master_id varchar(128),
state_province_id varchar(255),
postal_greeting_id varchar(16),
addressee_id varchar(16),
,
PRIMARY KEY ( id ),
INDEX index_street_address( street_address )
,
INDEX index_household_name( household_name )
,
INDEX index_civicrm_primary_id( civicrm_primary_id )
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci [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 '
PRIMARY KEY ( id ),
INDEX index_street_address( street_address )
,
INDEX i' at line 15]"]
)
Notice: Undefined index: sql_columns in CRM_Export_BAO_ExportProcessor->getSQLColumns() (line 927 of .../web/sites/all/modules/civicrm/CRM/Export/BAO/ExportProcessor.php