So I've got a query object with the following data in it (outputted into watchdog) - this is from hook_views_post_execute() -
[#conjunction] => OR  => Array ( [field] => SelectQuery Object ( [fields:protected] => Array ( [nid] => Array ( [field] => nid [table] => na [alias] => nid ) ) [value] => EXISTS [operator] => = )  => Array ( [field] => node.nid [value] => IS NULL [operator] => = )
Now as far as I can tell, according to this "OR" condition in db_select() this is how this is supposed to look for an OR condition.
However when I look at the string query for this, it looks like this:
WHERE (( (na.gid = :db_condition_placeholder_2) AND (na.realm = :db_condition_placeholder_3) )OR( (na.gid = :db_condition_placeholder_4) AND (na.realm = :db_condition_placeholder_5) )OR( (na.gid = :db_condition_placeholder_6) AND (na.realm = :db_condition_placeholder_7) )OR( (na.gid = :db_condition_placeholder_8) AND (na.realm = :db_condition_placeholder_9) ))AND (na.grant_view >= :db_condition_placeholder_10) AND (node.nid = na.nid) )OR (node.nid = :db_condition_placeholder_11)
:db_condition_placeholder_11 equaling IS NULL.
Now the actual query I want is something along the lines of this:
AND ( EXISTS (SELECT na.nid AS nid FROM node_access na WHERE (( (na.gid = 0) AND (na.realm = 'all') )OR( (na.gid = 117) AND (na.realm = 'content_access_author') )OR( (na.gid = 2) AND (na.realm = 'content_access_rid') )OR( (na.gid = 10) AND (na.realm = 'content_access_rid') )) AND (na.grant_view >= 1) AND (node_field_data_field_consultant_contact_er.nid = na.nid) ) OR node.nid <typically an entity reference to a node here> IS NULL )
I am generating it like this:
What exactly am I doing wrong? The $inside_subquery variable has all of the data that should be in the EXISTS in the above query.
Why does the string value differ from the query object?