Issue with SQL import with > and < in the SQL query
Overview
When using the SQL import datasource there is an issue in recent versions of CiviCRM due to the user job entity.
Reproduction steps
- Create table in database that contains at least a field called id and insert some rows, less than 15 would be enough
- Ensure that your role has permission to use the SQL datasource
- Click on Contacts -> Import Contacts.
- Select SQL mode and enter an SQL like
SELECT * FROM <table name> WHERE id > 5 AND id <= 12
. - Got an error "Fatal error: DB syntax error".
Expected behaviour
Should be able to move onto the Field mapping stepps
Environment information
- CiviCRM: 5.49.5
Comments
It seems to be because we are getting the sqlQuery from the userJob entity as per https://github.com/civicrm/civicrm-core/blob/master/CRM/Import/DataSource/SQL.php#L85 and https://github.com/civicrm/civicrm-core/blob/master/CRM/Import/DataSource.php#L225 and that seems to have an html encoded value for < and > so the query includes > etc rather than > in it
ping @eileen