Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-20647

Report generates incorrect SQL however under "Super User" is correct

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.7.19
    • Fix Version/s: None
    • Component/s: CiviReport
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding
    • Verified?:
      No

      Description

      We have a report that lists categories of vehicles depending on different criteria. The report is a custom one and is derived from "Contacts" under the "Constituent Report (Detail)" template.

      If I run the report as a non "Super User" it appends this piece of SQL to the generated select clause:

      AND `contact_civireport`.`is_deleted` != 1 AND `relationship_civireport`.`contact_id_a` IN (SELECT `id` FROM `civicrm_contact` WHERE is_deleted != 1) AND `relationship_civireport`.`contact_id_b` IN (SELECT `id` FROM `civicrm_contact` WHERE is_deleted != 1)

      which in turn generates this error:

      Database Error Code: Unknown column 'relationship_civireport.contact_id_a' in 'IN/ALL/ANY subquery', 1054.

      Running the report as a "Super User" the generated SQL does not have these lines and runs to completion.

      I have checked all the database tables and can see nothing in there which would suggest a reason for these additonal lines to be added.

       

      I have had an open question on the forum but no responses to it : https://civicrm.stackexchange.com/questions/18725/error-occurs-unknown-column-relationship-civireport-contact-id-a-however-not

        Attachments

        1. DB Error.png
          48 kB
          Paul Butler
        2. Member Report SQL Trace.txt
          25 kB
          Paul Butler

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              hetclub Paul Butler
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: