/**
 * Parse 'xprofile_query' argument passed to BP_User_Query.
 *
 * @since 2.2.0
 *
 * @param BP_User_Query $q User query object.
 */
function bp_xprofile_add_xprofile_query_to_user_query(BP_User_Query $q)
{
    // Bail if no `xprofile_query` clause.
    if (empty($q->query_vars['xprofile_query'])) {
        return;
    }
    $xprofile_query = new BP_XProfile_Query($q->query_vars['xprofile_query']);
    $sql = $xprofile_query->get_sql('u', $q->uid_name);
    if (!empty($sql['join'])) {
        $q->uid_clauses['select'] .= $sql['join'];
        $q->uid_clauses['where'] .= $sql['where'];
    }
}
 /**
  * @group BP7202
  */
 public function test_find_compatible_table_alias_should_match_negative_siblings_joined_with_relation_and()
 {
     $this->create_fields(1);
     $q = new BP_XProfile_Query(array('relation' => 'AND', array('field' => $this->fields[0], 'compare' => '!=', 'value' => 'foo'), array('field' => $this->fields[0], 'compare' => 'NOT IN', 'value' => array('bar', 'baz'))));
     $sql = $q->get_sql(buddypress()->profile->table_name_data, 'user_id');
     $this->assertSame(1, substr_count($sql['join'], 'INNER JOIN'));
 }