Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 4.2.2
-
Fix Version/s: None
-
Component/s: CiviCampaign, CiviContribute
-
Labels:
Description
Sorry, again, i find it hard to find issues, so not sure if that has been reported/fixed in newer versions.
Pretty much every view I set up with a relationship to an associated campaign is broken, the SQL generated is this (for example) -
SELECT civicrm_contribution.contribution_status_id AS civicrm_contribution_contribution_status_id, civicrm_contribution.contribution_type_id AS civicrm_contribution_contribution_type_id, civicrm_contribution.receive_date AS civicrm_contribution_receive_date, civicrm_contribution.source AS civicrm_contribution_source, civicrm_contribution.contact_id AS civicrm_contribution_contact_id, civicrm_contribution.id AS id, civicrm_contribution.total_amount AS civicrm_contribution_total_amount, civicrm_campaign_civicrm_contribution.title AS civicrm_campaign_civicrm_contribution_title, civicrm_value_project_campaign_fields_31.expense_sub_category_214 AS civicrm_value_project_campaign_fields_31_expense_sub_categor FROM civicrm_contribution civicrm_contribution LEFT JOIN civicrm_campaign civicrm_campaign_civicrm_contribution ON civicrm_contribution.id = civicrm_campaign_civicrm_contribution.id LEFT JOIN civicrm_value_project_campaign_fields_31 civicrm_value_project_campaign_fields_31 ON civicrm_contribution.id = civicrm_value_project_campaign_fields_31.entity_id WHERE civicrm_contribution.contribution_type_id in ('6')
it should be -
SELECT civicrm_contribution.contribution_status_id AS civicrm_contribution_contribution_status_id, civicrm_contribution.contribution_type_id AS civicrm_contribution_contribution_type_id, civicrm_contribution.receive_date AS civicrm_contribution_receive_date, civicrm_contribution.source AS civicrm_contribution_source, civicrm_contribution.contact_id AS civicrm_contribution_contact_id, civicrm_contribution.id AS id, civicrm_contribution.total_amount AS civicrm_contribution_total_amount, civicrm_campaign_civicrm_contribution.title AS civicrm_campaign_civicrm_contribution_title, civicrm_value_project_campaign_fields_31.expense_sub_category_214 AS civicrm_value_project_campaign_fields_31_expense_sub_categor FROM civicrm_contribution civicrm_contribution
LEFT JOIN civicrm_campaign civicrm_campaign_civicrm_contribution ON civicrm_contribution.campaign_id = civicrm_campaign_civicrm_contribution.id
LEFT JOIN civicrm_value_project_campaign_fields_31 civicrm_value_project_campaign_fields_31 ON civicrm_contribution.id = civicrm_value_project_campaign_fields_31.entity_id
WHERE civicrm_contribution.contribution_type_id in ('6')
Basically, the change is the Left Join
LEFT JOIN civicrm_campaign civicrm_campaign_civicrm_contribution ON civicrm_contribution.campaign_id = civicrm_campaign_civicrm_contribution.id
The original query was joining on the 'id' of the contribution, not the 'campaign_id'.
I'm going to fix this locally with some code overrides, but will contribute a patch when I get a chance if needed.