Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Won't Fix
-
Affects Version/s: 4.6.8, 4.7.1, 4.7.7
-
Fix Version/s: None
-
Component/s: CiviCRM API
-
Labels:
-
Documentation Required?:None
-
Funding Source:Needs Funding
Description
I have this problem on the Joomla demo site (4.6.0) and my own sites with versions 4.6.8 and 4.7.1.
If I use the API explorer or run test php code, with a query checking for multiple contact_sub_type, I get 0 results:
$result = civicrm_api3('Contact', 'get', array( 'sequential' => 1, 'return' => "contact_sub_type", 'contact_sub_type' => array('IN' => array("Student", "Parent")), ));
But if I search using the = operator for one contact_sub_type at a time, it returns the expected results:
$result = civicrm_api3('Contact', 'get', array( 'sequential' => 1, 'return' => "contact_sub_type", 'contact_sub_type' => "Parent", ));
{"is_error":0,"version":3,"count":1,"id":7,"values":[
{"contact_id":"7","contact_sub_type":["Parent"],"contact_is_deleted":"0","id":"7"}]}
This happens with subtypes of both Organization and Individual types.
I could work around it by performing multiple api calls and merging the results, but this seems like a bug?
---------------------------
Further experimentation with 4.7.7 on dmaster.demo.civicrm.org gives weird results.
I modified one contact to set sub_type as Student, and one contact to set as Parent.
Using API Explorer, I get these results:
$result = civicrm_api3('Contact', 'get', array( 'sequential' => 1, 'contact_sub_type' => array('IN' => array("Student", "Parent")), ));
returns one record - the Parent.
Running a query with contact_sub_type set to equal either Parent or Student returns the expected record.
Running a query with contact_sub_type in an array of either Parent or Student, such as
'contact_sub_type' => array('IN' => array("Parent")),
or
'contact_sub_type' => array('IN' => array("Student")),
returns 25 records (presumably matching a lot more, and just being limited to returning 25.)