From 38a85cdd76296dff98e8d830178b56829e9c2920 Mon Sep 17 00:00:00 2001 From: Jon goldberg Date: Tue, 9 Apr 2019 16:34:55 -0400 Subject: [PATCH] fix getAddressColumns() to respect tableAlias --- CRM/Report/Form.php | 2 +- tests/phpunit/api/v3/ReportTemplateTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index a136d9ef6c..a2cbb1c64c 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -5627,7 +5627,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a 'type' => CRM_Utils_Type::T_INT, 'no_display' => TRUE, 'required' => TRUE, - 'dbAlias' => '(address_civireport.street_number % 2)', + 'dbAlias' => "({$tableAlias}_civireport.street_number % 2)", 'is_fields' => TRUE, 'is_order_bys' => TRUE, ], diff --git a/tests/phpunit/api/v3/ReportTemplateTest.php b/tests/phpunit/api/v3/ReportTemplateTest.php index b2eb935a18..baa1cfe47e 100644 --- a/tests/phpunit/api/v3/ReportTemplateTest.php +++ b/tests/phpunit/api/v3/ReportTemplateTest.php @@ -1226,4 +1226,18 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $this->assertEquals(2, $values['civicrm_contribution_soft_soft_id_count'], "Total donors should be 2"); } + /** + * Test a report that uses getAddressColumns(); + */ + public function testGetAddressColumns() { + $template = 'event/participantlisting'; + $rows = $this->callAPISuccess('report_template', 'getrows', [ + 'report_id' => $template, + 'fields' => [ + 'sort_name' => '1', + 'street_address' => '1', + ], + ]); + } + } -- 2.25.1