The EFQ is:
$query->entityCondition('entity_type', 'node')
->fieldCondition('field_terms_wb_access', 'tid', array_keys($children), 'NOT IN')
->fieldCondition('field_terms_wb_access', 'tid', $tid, '=')
->propertyOrderBy('title');
and the query being generated is
SELECT DISTINCT
field_data_field_terms_wb_access0.entity_type AS entity_type,
field_data_field_terms_wb_access0.entity_id AS entity_id,
field_data_field_terms_wb_access0.revision_id AS revision_id,
field_data_field_terms_wb_access0.bundle AS bundle
FROM {field_data_field_terms_wb_access}
field_data_field_terms_wb_access0
INNER JOIN {field_data_field_terms_wb_access}
field_data_field_terms_wb_access1
ON field_data_field_terms_wb_access1.entity_type = field_data_field_terms_wb_access0.entity_type
AND field_data_field_terms_wb_access1.entity_id = field_data_field_terms_wb_access0.entity_id
INNER JOIN {node} node
ON node.nid = field_data_field_terms_wb_access0.entity_id
WHERE (
field_data_field_terms_wb_access0.field_terms_wb_access_tid
NOT IN (
:db_condition_placeholder_0,
:db_condition_placeholder_1,
:db_condition_placeholder_2,
[...]
:db_condition_placeholder_22
)
)
AND (
field_data_field_terms_wb_access1.field_terms_wb_access_tid = :db_condition_placeholder_23
)
AND (
field_data_field_terms_wb_access0.deleted = :db_condition_placeholder_24
)
AND (
field_data_field_terms_wb_access0.entity_type = :db_condition_placeholder_25
)
ORDER BY node.title ASC
However, why I include both fieldCondition('field_terms_wb_access', 'tid', $tid, '=')
AND fieldCondition('field_terms_wb_access', 'tid', array_keys($children), 'NOT IN')
clauses, it seems to only honor the first one and ignore the second. If I comment out the first one, however, then the second one is honored. I get no errors in the php error log or on the screen.