I have a query tagged QueryAlterableInterface that I need to add an item to the IN clause I want to alter the term_access query and it's tagged in QueryAlterableInterface. There are items I want to add to an IN clause that's been altered before my module.

I've tried something 

$query-&gt;condition('ga.gid', $new_items, 'IN');


But that just adds a new db_placeholder_n to the arguments array without altering the query itself.

Query is:

SELECT DISTINCT base.tid AS tid, base.vid AS vid, base.name AS name, base.description AS description, base.format AS format, base.weight AS weight, base.uuid AS uuid, v.machine_name AS vocabulary_machine_name
FROM {taxonomy_term_data} base
INNER JOIN {taxonomy_vocabulary} v ON base.vid = v.vid
LEFT OUTER JOIN {og_membership} ga ON ga.etid = base.tid
AND ga.entity_type = :entity_type
AND ga.field_name = :field_name
WHERE  (base.tid IN  (:db_condition_placeholder_1)) AND( (ga.gid IS NULL ) OR( (ga.group_type = :db_condition_placeholder_2) AND (ga.gid IN  (:db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5)) ))
Ok here's what happened. Basically, I had to unset the conditions and then just rewrite all of them. Any better solutions I will accept as the answer but this is how I solved it.

$where =&amp; $query-&gt;conditions();

if(empty($where[1])) {
  return;
}

unset($where['1']);
$list = my_custom_function_to_get_groups();

$groups = array();

foreach($list as $group) {
  if(!empty($group-&gt;nid)) {
    $groups[] = $group-&gt;nid;     
  }
}

$query-&gt;condition('ga.gid', $groups, 'IN');