CRM-18055 Fatal error in reports with some custom fields

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 4.7.1, 4.7.2
    • Fix Version/s: None
    • Component/s: CiviReport
    • Labels:
      None
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      Using either 4.7.1 or 4.7.2 I get a fatal error when I use reports that ran great on 4.6.9.

      It seems some custom field groups do not get included in the LEFT JOIN resulting in a fatal error: Unknown column 'value_cv_118_civireport.welke_jaren_mee_als_deelnemer__376' in 'field list']

      I am going to help diagnose further and hope someone jumps on this wagon to be able to fix this nasty one.
      [Edited: On further analysis I found out that a required LEFT JOIN for the custom field that is selected omitted from the report query. See attached screenshot.]

      Possibly related issues:
      https://issues.civicrm.org/jira/browse/CRM-18010
      https://issues.civicrm.org/jira/browse/CRM-18048
      https://issues.civicrm.org/jira/browse/CRM-18051

        Attachments

          Activity

          [CRM-18055] Fatal error in reports with some custom fields
          Richard added a comment - - edited

          Added screenshot of the report query that throws the fatal error, and the manually crafted query how it should be (tested in phpmyadmin).

          For a reason I cannot grasp when the customfield is selected the relevant LEFT JOIN is not added in civicrm 4.7.x

          #QUERY FROM CIVICRM 4.7.x (4.7.1/4.7.2)

          SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, contact_civireport.id as civicrm_contact_id, value_drijfveren_69_civireport.motivatie_337 as civicrm_value_drijfveren_69_custom_337, value_cv_118_civireport.welke_jaren_mee_als_deelnemer__376 as civicrm_value_cv_118_custom_376
          FROM civicrm_contact contact_civireport
          LEFT JOIN civicrm_address address_civireport
          ON (contact_civireport.id = address_civireport.contact_id AND
          address_civireport.is_primary = 1 )
          LEFT JOIN civicrm_value_drijfveren_69 value_drijfveren_69_civireport
          ON value_drijfveren_69_civireport.entity_id = contact_civireport.id
          WHERE ( contact_civireport.gender_id IN (2) ) AND contact_civireport.is_deleted = 0
          ORDER BY contact_civireport.sort_name ASC LIMIT 0, 50

          [nativecode=1054 ** Unknown column 'value_cv_118_civireport.welke_jaren_mee_als_deelnemer__376' in 'field list']

          #PROPER QUERY (manually added last LEFT JOIN):

          SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, contact_civireport.id as civicrm_contact_id, value_drijfveren_69_civireport.motivatie_337 as civicrm_value_drijfveren_69_custom_337, value_cv_118_civireport.welke_jaren_mee_als_deelnemer__376 as civicrm_value_cv_118_custom_376
          FROM civicrm_contact contact_civireport
          LEFT JOIN civicrm_address address_civireport
          ON (contact_civireport.id = address_civireport.contact_id AND
          address_civireport.is_primary = 1 )
          LEFT JOIN civicrm_value_drijfveren_69 value_drijfveren_69_civireport
          ON value_drijfveren_69_civireport.entity_id = contact_civireport.id
          LEFT JOIN civicrm_value_cv_118 value_cv_118_civireport
          ON value_cv_118_civireport.id = contact_civireport.id
          WHERE ( contact_civireport.gender_id IN (2) ) AND contact_civireport.is_deleted = 0
          ORDER BY contact_civireport.sort_name ASC LIMIT 0, 50

          So the line:
          LEFT JOIN civicrm_value_cv_118 value_cv_118_civireport
          ON value_cv_118_civireport.id = contact_civireport.id
          is not added to the query when the custom field is selected.
          causing a fatal error:
          [nativecode=1054 ** Unknown column 'value_cv_118_civireport.welke_jaren_mee_als_deelnemer__376' in 'field list']

          Coleman Watts added a comment -

          Richard all those related issues you linked have been fixed. Can you confirm this bug is still present in the latest version?
          Could you provide steps to reproduce it on the demo server?

          Richard added a comment -

          The problems seem all to be vanished in 4.7.6 So I believe this issue can be closed

          Coleman Watts added a comment -

          Hooray!

            People

            • Assignee:
              Unassigned
              Reporter:
              Richard

              Dates

              • Created:
                Updated:
                Resolved: