From 96a3c9a18cd16f93a446c56962c6a8e2098bf113 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 31 May 2019 12:23:26 +1200 Subject: [PATCH] Standardise custom fields metadata --- CRM/Core/BAO/CustomField.php | 34 +- .../phpunit/CRM/Core/BAO/CustomFieldTest.php | 305 ++++++++++++------ .../phpunit/CRM/Core/BAO/CustomQueryTest.php | 6 + 3 files changed, 230 insertions(+), 115 deletions(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 2b1e74ad4c75..8d22e52f2198 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -635,10 +635,18 @@ public static function &getFields( $fields = array(); while (($dao->fetch()) != NULL) { + $regexp = preg_replace('/[.,;:!?]/', '', NULL); $fields[$dao->id]['id'] = $dao->id; $fields[$dao->id]['label'] = $dao->label; + // This seems broken, but not in a new way. + $fields[$dao->id]['headerPattern'] = '/' . preg_quote($regexp, '/') . '/'; + // To support the consolidation of various functions & their expectations. + $fields[$dao->id]['title'] = $dao->label; + $fields[$dao->id]['custom_field_id'] = $dao->id; $fields[$dao->id]['groupTitle'] = $dao->title; $fields[$dao->id]['data_type'] = $dao->data_type; + $fields[$dao->id]['name'] = 'custom_' . $dao->id; + $fields[$dao->id]['type'] = CRM_Utils_Array::value($dao->data_type, self::dataToType()); $fields[$dao->id]['html_type'] = $dao->html_type; $fields[$dao->id]['default_value'] = $dao->default_value; $fields[$dao->id]['text_length'] = $dao->text_length; @@ -656,6 +664,7 @@ public static function &getFields( $fields[$dao->id]['is_required'] = $dao->is_required; $fields[$dao->id]['table_name'] = $dao->table_name; $fields[$dao->id]['column_name'] = $dao->column_name; + $fields[$dao->id]['where'] = $dao->table_name . '.' . $dao->column_name; // Probably we should use a different fn to get the extends tables but this is a refactor so not changing that now. $fields[$dao->id]['extends_table'] = array_key_exists($dao->extends, CRM_Core_BAO_CustomQuery::$extendsMap) ? CRM_Core_BAO_CustomQuery::$extendsMap[$dao->extends] : ''; if (in_array($dao->extends, CRM_Contact_BAO_ContactType::subTypes())) { @@ -716,7 +725,7 @@ public static function getFieldsForImport( $checkPermission ); - $importableFields = array(); + $importableFields = []; foreach ($fields as $id => $values) { // for now we should not allow multiple fields in profile / export etc, hence unsetting if (!$search && @@ -728,27 +737,8 @@ public static function getFieldsForImport( /* generate the key for the fields array */ $key = "custom_$id"; - - $regexp = preg_replace('/[.,;:!?]/', '', CRM_Utils_Array::value(0, $values)); - $importableFields[$key] = array( - 'name' => $key, - 'type' => CRM_Utils_Array::value(CRM_Utils_Array::value('data_type', $values), self::dataToType()), - 'title' => CRM_Utils_Array::value('label', $values), - 'headerPattern' => '/' . preg_quote($regexp, '/') . '/', - 'import' => 1, - 'custom_field_id' => $id, - 'options_per_line' => CRM_Utils_Array::value('options_per_line', $values), - 'text_length' => CRM_Utils_Array::value('text_length', $values, 255), - 'data_type' => CRM_Utils_Array::value('data_type', $values), - 'html_type' => CRM_Utils_Array::value('html_type', $values), - 'is_search_range' => CRM_Utils_Array::value('is_search_range', $values), - ); - - // CRM-6681, pass date and time format when html_type = Select Date - if (CRM_Utils_Array::value('html_type', $values) == 'Select Date') { - $importableFields[$key]['date_format'] = CRM_Utils_Array::value('date_format', $values); - $importableFields[$key]['time_format'] = CRM_Utils_Array::value('time_format', $values); - } + $importableFields[$key] = $values; + $importableFields[$key]['import'] = 1; } return $importableFields; diff --git a/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php b/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php index 83284700f5d8..be383b14b90f 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php @@ -20,14 +20,14 @@ public function testCreateCustomField() { $customFieldID = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup['id'], 'id', 'custom_group_id', 'Database check for created CustomField.' ); - $fields = [ + $fields = array( 'id' => $customFieldID, 'label' => 'editTestFld', 'is_active' => 1, 'data_type' => 'String', 'html_type' => 'Text', 'custom_group_id' => $customGroup['id'], - ]; + ); CRM_Core_BAO_CustomField::create($fields); $this->assertDBNotNull('CRM_Core_DAO_CustomField', 1, 'id', 'is_active', 'Database check for edited CustomField.'); @@ -42,14 +42,14 @@ public function testCreateCustomField() { } public function testCreateCustomFieldColumnName() { - $customGroup = $this->customGroupCreate(['extends' => 'Individual']); - $fields = [ + $customGroup = $this->customGroupCreate(array('extends' => 'Individual')); + $fields = array( 'label' => 'testFld 2', 'column_name' => 'special_colname', 'data_type' => 'String', 'html_type' => 'Text', 'custom_group_id' => $customGroup['id'], - ]; + ); CRM_Core_BAO_CustomField::create($fields); $customFieldID = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup['id'], 'id', 'custom_group_id', 'Database check for created CustomField.' @@ -62,14 +62,14 @@ public function testCreateCustomFieldColumnName() { } public function testCreateCustomFieldName() { - $customGroup = $this->customGroupCreate(['extends' => 'Individual']); - $fields = [ + $customGroup = $this->customGroupCreate(array('extends' => 'Individual')); + $fields = array( 'label' => 'testFld 2', 'name' => 'special_fldlname', 'data_type' => 'String', 'html_type' => 'Text', 'custom_group_id' => $customGroup['id'], - ]; + ); CRM_Core_BAO_CustomField::create($fields); $customFieldID = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup['id'], 'id', 'custom_group_id', 'Database check for created CustomField.' @@ -82,25 +82,25 @@ public function testCreateCustomFieldName() { } public function testGetFields() { - $customGroup = $this->customGroupCreate(['extends' => 'Individual']); - $fields = [ + $customGroup = $this->customGroupCreate(array('extends' => 'Individual')); + $fields = array( 'label' => 'testFld1', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroup['id'], - ]; + ); CRM_Core_BAO_CustomField::create($fields); $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup['id'], 'id', 'custom_group_id', 'Database check for created CustomField.' ); - $fields = [ + $fields = array( 'label' => 'testFld2', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroup['id'], - ]; + ); CRM_Core_BAO_CustomField::create($fields); $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup['id'], 'id', 'custom_group_id', 'Database check for created CustomField.' @@ -110,68 +110,68 @@ public function testGetFields() { } public function testGetDisplayedValues() { - $customGroup = $this->customGroupCreate(['extends' => 'Individual']); - $fieldsToCreate = [ - [ + $customGroup = $this->customGroupCreate(array('extends' => 'Individual')); + $fieldsToCreate = array( + array( 'data_type' => 'Country', 'html_type' => 'Select Country', - 'tests' => [ + 'tests' => array( 'United States' => 1228, '' => NULL, - ], - ], - [ + ), + ), + array( 'data_type' => 'StateProvince', 'html_type' => 'Multi-Select State/Province', - 'tests' => [ + 'tests' => array( '' => 0, 'Alabama' => 1000, - 'Alabama, Alaska' => [1000, 1001], - ], - ], - [ + 'Alabama, Alaska' => array(1000, 1001), + ), + ), + array( 'data_type' => 'String', 'html_type' => 'Radio', - 'option_values' => [ + 'option_values' => array( 'key' => 'KeyLabel', - ], - 'tests' => [ + ), + 'tests' => array( 'KeyLabel' => 'key', - ], - ], - [ + ), + ), + array( 'data_type' => 'String', 'html_type' => 'CheckBox', - 'option_values' => [ + 'option_values' => array( 'key1' => 'Label1', 'key2' => 'Label2', 'key3' => 'Label3', 'key4' => 'Label4', - ], - 'tests' => [ - 'Label1' => ['key1'], + ), + 'tests' => array( + 'Label1' => array('key1'), 'Label2' => 'key2', - 'Label2, Label3' => ['key2', 'key3'], - 'Label3, Label4' => CRM_Utils_Array::implodePadded(['key3', 'key4']), - 'Label1, Label4' => ['key1' => 1, 'key4' => 1], - ], - ], - [ + 'Label2, Label3' => array('key2', 'key3'), + 'Label3, Label4' => CRM_Utils_Array::implodePadded(array('key3', 'key4')), + 'Label1, Label4' => array('key1' => 1, 'key4' => 1), + ), + ), + array( 'data_type' => 'Date', 'html_type' => 'Select Date', 'date_format' => 'd M yy', 'time_format' => 1, - 'tests' => [ + 'tests' => array( '1 Jun 1999 1:30PM' => '1999-06-01 13:30', '' => '', - ], - ], - ]; + ), + ), + ); foreach ($fieldsToCreate as $num => $field) { - $params = $field + [ - 'label' => 'test field ' . $num, - 'custom_group_id' => $customGroup['id'], - ]; + $params = $field + array( + 'label' => 'test field ' . $num, + 'custom_group_id' => $customGroup['id'], + ); unset($params['tests']); $createdField = $this->callAPISuccess('customField', 'create', $params); foreach ($field['tests'] as $expected => $input) { @@ -203,13 +203,13 @@ public function testGetDisplayedValuesContactRef() { } public function testDeleteCustomField() { - $customGroup = $this->customGroupCreate(['extends' => 'Individual']); - $fields = [ + $customGroup = $this->customGroupCreate(array('extends' => 'Individual')); + $fields = array( 'custom_group_id' => $customGroup['id'], 'label' => 'Throwaway Field', 'dataType' => 'Memo', 'htmlType' => 'TextArea', - ]; + ); $customField = $this->customFieldCreate($fields); $fieldObject = new CRM_Core_BAO_CustomField(); @@ -230,75 +230,75 @@ public function testDeleteCustomField() { public function testMoveField() { $countriesByName = array_flip(CRM_Core_PseudoConstant::country(FALSE, FALSE)); $this->assertTrue($countriesByName['Andorra'] > 0); - $groups = [ - 'A' => $this->customGroupCreate([ + $groups = array( + 'A' => $this->customGroupCreate(array( 'title' => 'Test_Group A', 'name' => 'test_group_a', - 'extends' => ['Individual'], + 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3, - ]), - 'B' => $this->customGroupCreate([ + )), + 'B' => $this->customGroupCreate(array( 'title' => 'Test_Group B', 'name' => 'test_group_b', - 'extends' => ['Individual'], + 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3, - ]), - ]; + )), + ); $groupA = $groups['A']['values'][$groups['A']['id']]; $groupB = $groups['B']['values'][$groups['B']['id']]; - $countryA = $this->customFieldCreate([ + $countryA = $this->customFieldCreate(array( 'custom_group_id' => $groups['A']['id'], 'label' => 'Country A', 'dataType' => 'Country', 'htmlType' => 'Select Country', 'default_value' => NULL, - ]); - $countryB = $this->customFieldCreate([ + )); + $countryB = $this->customFieldCreate(array( 'custom_group_id' => $groups['A']['id'], 'label' => 'Country B', 'dataType' => 'Country', 'htmlType' => 'Select Country', 'default_value' => NULL, - ]); - $countryC = $this->customFieldCreate([ + )); + $countryC = $this->customFieldCreate(array( 'custom_group_id' => $groups['B']['id'], 'label' => 'Country C', 'dataType' => 'Country', 'htmlType' => 'Select Country', 'default_value' => NULL, - ]); + )); - $fields = [ + $fields = array( 'countryA' => $countryA['values'][$countryA['id']], 'countryB' => $countryB['values'][$countryB['id']], 'countryC' => $countryC['values'][$countryC['id']], - ]; - $contacts = [ - 'alice' => $this->individualCreate([ + ); + $contacts = array( + 'alice' => $this->individualCreate(array( 'first_name' => 'Alice', 'last_name' => 'Albertson', 'custom_' . $fields['countryA']['id'] => $countriesByName['Andorra'], 'custom_' . $fields['countryB']['id'] => $countriesByName['Barbados'], - ]), - 'bob' => $this->individualCreate([ + )), + 'bob' => $this->individualCreate(array( 'first_name' => 'Bob', 'last_name' => 'Roberts', 'custom_' . $fields['countryA']['id'] => $countriesByName['Austria'], 'custom_' . $fields['countryB']['id'] => $countriesByName['Bermuda'], 'custom_' . $fields['countryC']['id'] => $countriesByName['Chad'], - ]), - 'carol' => $this->individualCreate([ + )), + 'carol' => $this->individualCreate(array( 'first_name' => 'Carol', 'last_name' => 'Carolson', 'custom_' . $fields['countryC']['id'] => $countriesByName['Cambodia'], - ]), - ]; + )), + ); // Move! CRM_Core_BAO_CustomField::moveField($fields['countryB']['id'], $groupB['id']); @@ -319,10 +319,10 @@ public function testMoveField() { WHERE entity_id = %1 AND {$fields['countryB']['column_name']} = %3 AND {$fields['countryC']['column_name']} is null", - [ - 1 => [$contacts['alice'], 'Integer'], - 3 => [$countriesByName['Barbados'], 'Integer'], - ] + array( + 1 => array($contacts['alice'], 'Integer'), + 3 => array($countriesByName['Barbados'], 'Integer'), + ) ); // Bob: Group[B] has merged fields[countryB] and fields[countryC] on the same record @@ -331,11 +331,11 @@ public function testMoveField() { WHERE entity_id = %1 AND {$fields['countryB']['column_name']} = %3 AND {$fields['countryC']['column_name']} = %4", - [ - 1 => [$contacts['bob'], 'Integer'], - 3 => [$countriesByName['Bermuda'], 'Integer'], - 4 => [$countriesByName['Chad'], 'Integer'], - ] + array( + 1 => array($contacts['bob'], 'Integer'), + 3 => array($countriesByName['Bermuda'], 'Integer'), + 4 => array($countriesByName['Chad'], 'Integer'), + ) ); // Carol: Group[B] still has fields[countryC] but did not get fields[countryB] @@ -344,10 +344,10 @@ public function testMoveField() { WHERE entity_id = %1 AND {$fields['countryB']['column_name']} is null AND {$fields['countryC']['column_name']} = %4", - [ - 1 => [$contacts['carol'], 'Integer'], - 4 => [$countriesByName['Cambodia'], 'Integer'], - ] + array( + 1 => array($contacts['carol'], 'Integer'), + 4 => array($countriesByName['Cambodia'], 'Integer'), + ) ); $this->customGroupDelete($groups['A']['id']); @@ -399,14 +399,17 @@ protected function createCustomField($groupTitle = 'new custom group') { } /** - * Tet the getFieldsForImport function. + * Test the getFieldsForImport function. + * + * @throws \Exception */ public function testGetFieldsForImport() { $this->entity = 'Contact'; $this->createCustomGroupWithFieldsOfAllTypes(); + $customGroupID = $this->ids['CustomGroup']['Custom Group']; $expected = [ $this->getCustomFieldName('country') => [ - 'name' => $this->getCustomFieldName('country') , + 'name' => $this->getCustomFieldName('country'), 'type' => 1, 'title' => 'Country', 'headerPattern' => '//', @@ -417,8 +420,27 @@ public function testGetFieldsForImport() { 'data_type' => 'Int', 'html_type' => 'Select Country', 'is_search_range' => '0', + 'id' => $this->getCustomFieldID('country'), + 'label' => 'Country', + 'groupTitle' => 'Custom Group', + 'default_value' => NULL, + 'custom_group_id' => $customGroupID, + 'extends' => 'Contact', + 'extends_entity_column_value' => NULL, + 'extends_entity_column_id' => NULL, + 'is_view' => '0', + 'is_multiple' => '0', + 'option_group_id' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'is_required' => '0', + 'table_name' => 'civicrm_value_custom_group_' . $customGroupID, + 'column_name' => 'country_' . $this->getCustomFieldID('country'), + 'where' => 'civicrm_value_custom_group_' . $customGroupID . '.country_' . $this->getCustomFieldID('country'), + 'extends_table' => 'civicrm_contact', + 'search_table' => 'contact_a', ], - $this->getCustomFieldName('file') => [ + $this->getCustomFieldName('file') => [ 'name' => $this->getCustomFieldName('file'), 'type' => 2, 'title' => 'Custom Field', @@ -430,6 +452,25 @@ public function testGetFieldsForImport() { 'data_type' => 'File', 'html_type' => 'File', 'is_search_range' => '0', + 'id' => $this->getCustomFieldID('file'), + 'label' => 'Custom Field', + 'groupTitle' => 'Custom Group', + 'default_value' => NULL, + 'custom_group_id' => $customGroupID, + 'extends' => 'Contact', + 'extends_entity_column_value' => NULL, + 'extends_entity_column_id' => NULL, + 'is_view' => '0', + 'is_multiple' => '0', + 'option_group_id' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'is_required' => '0', + 'table_name' => 'civicrm_value_custom_group_' . $customGroupID, + 'column_name' => 'custom_field_' . $this->getCustomFieldID('file'), + 'where' => 'civicrm_value_custom_group_1.custom_field_' . $this->getCustomFieldID('file'), + 'extends_table' => 'civicrm_contact', + 'search_table' => 'contact_a', ], $this->getCustomFieldName('text') => [ 'name' => $this->getCustomFieldName('text'), @@ -443,9 +484,28 @@ public function testGetFieldsForImport() { 'data_type' => 'String', 'html_type' => 'Text', 'is_search_range' => '0', + 'id' => $this->getCustomFieldID('text'), + 'label' => 'Enter text here', + 'groupTitle' => 'Custom Group', + 'default_value' => 'xyz', + 'custom_group_id' => '1', + 'extends' => 'Contact', + 'extends_entity_column_value' => NULL, + 'extends_entity_column_id' => NULL, + 'is_view' => '0', + 'is_multiple' => '0', + 'option_group_id' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'is_required' => '1', + 'table_name' => 'civicrm_value_custom_group_' . $customGroupID, + 'column_name' => 'enter_text_here_' . $this->getCustomFieldID('text'), + 'where' => 'civicrm_value_custom_group_' . $customGroupID . '.enter_text_here_' . $this->getCustomFieldID('text'), + 'extends_table' => 'civicrm_contact', + 'search_table' => 'contact_a', ], $this->getCustomFieldName('select_string') => [ - 'name' => $this->getCustomFieldName('select_string'), + 'name' => $this->getCustomFieldName('select_string'), 'type' => 2, 'title' => 'Pick Color', 'headerPattern' => '//', @@ -456,6 +516,29 @@ public function testGetFieldsForImport() { 'data_type' => 'String', 'html_type' => 'Select', 'is_search_range' => '0', + 'id' => $this->getCustomFieldID('select_string'), + 'label' => 'Pick Color', + 'groupTitle' => 'Custom Group', + 'default_value' => NULL, + 'custom_group_id' => $customGroupID, + 'extends' => 'Contact', + 'extends_entity_column_value' => NULL, + 'extends_entity_column_id' => NULL, + 'is_view' => '0', + 'is_multiple' => '0', + 'option_group_id' => $this->callAPISuccessGetValue('CustomField', ['id' => $this->getCustomFieldID('select_string'), 'return' => 'option_group_id']), + 'date_format' => NULL, + 'time_format' => NULL, + 'is_required' => '1', + 'table_name' => 'civicrm_value_custom_group_' . $customGroupID, + 'column_name' => 'pick_color_' . $this->getCustomFieldID('select_string'), + 'where' => 'civicrm_value_custom_group_' . $customGroupID . '.pick_color_' . $this->getCustomFieldID('select_string'), + 'extends_table' => 'civicrm_contact', + 'search_table' => 'contact_a', + 'pseudoconstant' => [ + 'optionGroupName' => $this->callAPISuccessGetValue('CustomField', ['id' => $this->getCustomFieldID('select_string'), 'return' => 'option_group_id.name']), + 'optionEditPath' => 'civicrm/admin/options/' . $this->callAPISuccessGetValue('CustomField', ['id' => $this->getCustomFieldID('select_string'), 'return' => 'option_group_id.name']), + ], ], $this->getCustomFieldName('select_date') => [ 'name' => $this->getCustomFieldName('select_date'), @@ -471,6 +554,23 @@ public function testGetFieldsForImport() { 'is_search_range' => '0', 'date_format' => 'mm/dd/yy', 'time_format' => '1', + 'id' => $this->getCustomFieldID('select_date'), + 'label' => 'test_date', + 'groupTitle' => 'Custom Group', + 'default_value' => '20090711', + 'custom_group_id' => $customGroupID, + 'extends' => 'Contact', + 'extends_entity_column_value' => NULL, + 'extends_entity_column_id' => NULL, + 'is_view' => '0', + 'is_multiple' => '0', + 'option_group_id' => NULL, + 'is_required' => '0', + 'table_name' => 'civicrm_value_custom_group_' . $customGroupID, + 'column_name' => 'test_date_' . $this->getCustomFieldID('select_date'), + 'where' => 'civicrm_value_custom_group_' . $customGroupID . '.test_date_' . $this->getCustomFieldID('select_date'), + 'extends_table' => 'civicrm_contact', + 'search_table' => 'contact_a', ], $this->getCustomFieldName('link') => [ 'name' => $this->getCustomFieldName('link'), @@ -484,6 +584,25 @@ public function testGetFieldsForImport() { 'data_type' => 'Link', 'html_type' => 'Link', 'is_search_range' => '0', + 'id' => $this->getCustomFieldID('link'), + 'label' => 'test_link', + 'groupTitle' => 'Custom Group', + 'default_value' => 'http://civicrm.org', + 'custom_group_id' => $customGroupID, + 'extends' => 'Contact', + 'extends_entity_column_value' => NULL, + 'extends_entity_column_id' => NULL, + 'is_view' => '0', + 'is_multiple' => '0', + 'option_group_id' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'is_required' => '1', + 'table_name' => 'civicrm_value_custom_group_' . $customGroupID, + 'column_name' => 'test_link_' . $this->getCustomFieldID('link'), + 'where' => 'civicrm_value_custom_group_' . $customGroupID . '.test_link_' . $this->getCustomFieldID('link'), + 'extends_table' => 'civicrm_contact', + 'search_table' => 'contact_a', ], ]; $this->assertEquals($expected, CRM_Core_BAO_CustomField::getFieldsForImport()); diff --git a/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php b/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php index ab266df34a44..ce496704d841 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php @@ -74,6 +74,12 @@ public function testSearchCustomDataDateRelative() { 'is_required' => '0', 'extends_table' => 'civicrm_contact', 'search_table' => 'contact_a', + 'headerPattern' => '//', + 'title' => 'date field', + 'custom_field_id' => $dateCustomField['id'], + 'name' => 'custom_' . $dateCustomField['id'], + 'type' => 4, + 'where' => 'civicrm_value_testsearchcus_' . $ids['custom_group_id'] . '.date_field_' . $dateCustomField['id'], ], $queryObj->getFields()[$dateCustomField['id']]); }