Skip to content

Fatal error in uniondatasource "The used SELECT statements have a different number of columns" #31

@rhelms

Description

@rhelms

Hi. I'm supporting an older release of Symphony CMS (2.2.5), using the uniondatasource (0.6).

I'm getting a Symphony Fatal Error, due to a different number of columns.

SELECT SQL_CACHE `e`.id as id, `e`.section_id, e.`author_id`, UNIX_TIMESTAMP(e.`creation_date`) AS `creation_date` 
FROM `sym_entries` AS `e` 
LEFT JOIN `sym_entries_data_3` AS t3_1 ON (e.id = t3_1.entry_id) 
WHERE `e`.`section_id` = 1 AND ( t3_1.value IN ('yes') OR t3_1.value IS NULL ) 
UNION ALL 
SELECT `e`.id as id, `e`.section_id, e.`author_id`, UNIX_TIMESTAMP(e.`creation_date`) AS `creation_date` 
FROM `sym_entries` AS `e` 
WHERE `e`.`section_id` = 7 
UNION ALL 
SELECT `e`.id as id, `e`.section_id, e.`author_id`, UNIX_TIMESTAMP(e.`creation_date`) AS `creation_date`, `ed`.value 
FROM `sym_entries` AS `e` 
LEFT JOIN `sym_entries_data_25` AS t25_1 ON (e.id = t25_1.entry_id) 
LEFT OUTER JOIN `sym_entries_data_50` AS `ed` ON (`e`.`id` = `ed`.`entry_id`) 
WHERE `e`.`section_id` = 6 AND ( t25_1.value IN ('yes') OR t25_1.value IS NULL ) 
ORDER BY id desc LIMIT 0, 20
  • formatted for readability

The usage for three data sources, where two of them order by 'system:id', and the third by a field called 'order'.

I think the error occurs because the third datasource results in $sort_field being populated, and the extra field appended.

It would seem that $sort_field should always be calculated, regardless of the sort field, or a nonce use for that extra field, in the case where $sort_field is not populated.

This might impact the latest release of the extension, as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions