Details
Description
This is probably a work in progress for someone but logging it in case it hasn't been spotted (it's somewhat masked in test results by CRM-8950)
Basic participant query is returning (API participant test) is returning field discount_name.label
but discount_name is the option_group table (which doesn't have a label field). Discount label is in option_value. Ergo query from BAO Query object is wrong.
discount_name.label as participant_discount_name,
LEFT JOIN civicrm_option_group discount_name
SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`, contact_a.display_name as `display_name`, civicrm_event.id as event_id, civicrm_event.title as event_title, civicrm_event.start_date as event_start_date, civicrm_event.end_date as event_end_date, civicrm_participant.id as participant_id, civicrm_participant.fee_level as participant_fee_level, civicrm_participant.fee_amount as participant_fee_amount, civicrm_participant.fee_currency as participant_fee_currency, event_type.label as event_type, participant_status.label as participant_status, participant_status.id as participant_status_id, civicrm_participant.role_id as participant_role_id, civicrm_participant.register_date as participant_register_date, civicrm_participant.source as participant_source, civicrm_note.note as participant_note, civicrm_participant.is_pay_later as participant_is_pay_later, civicrm_participant.is_test as participant_is_test, civicrm_participant.registered_by_id as participant_registered_by_id, discount_name.label as participant_discount_name, civicrm_participant.campaign_id as participant_campaign_id FROM civicrm_contact contact_a LEFT JOIN civicrm_participant ON civicrm_participant.contact_id = contact_a.id INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id LEFT JOIN civicrm_option_group option_group_event_type ON (option_group_event_type.name = 'event_type') LEFT JOIN civicrm_option_value event_type ON (civicrm_event.event_type_id = event_type.value AND option_group_event_type.id = event_type.option_group_id ) LEFT JOIN civicrm_discount discount ON ( civicrm_participant.discount_id = discount.id ) LEFT JOIN civicrm_option_group discount_name ON ( discount_name.id = discount.option_group_id ) LEFT JOIN civicrm_note ON ( civicrm_note.entity_table = 'civicrm_participant' AND
civicrm_participant.id = civicrm_note.entity_id ) LEFT JOIN civicrm_option_group option_group_participant_role ON (option_group_participant_role.name = 'participant_role') LEFT JOIN civicrm_option_value participant_role ON (civicrm_participant.role_id = participant_role.value
AND option_group_participant_role.id = participant_role.option_group_id ) LEFT JOIN civicrm_participant_status_type participant_status ON (civicrm_participant.status_id = participant_status.id) WHERE ( civicrm_participant.id = 7 AND civicrm_participant.is_test = 0 ) LIMIT 0, 25