By fiasst-1 on
Hi, so I'm trying to add the term_node table to a view within views_query_alter(). If I add a taxonomy Term TID within the Views UI, the $query structure includes 'type' => INNER for the term_node table. Whereas when I programmatically add the table with add_table() the 'type' is set to LEFT. I'm out of ideas...
Example outputs below:
$query output after adding Term TID filter via views UI:
views_query Object
(
[table_queue] => Array
(
[node] => Array
(
[alias] => node
[table] => node
[relationship] => node
[join] =>
)
[uc_product_stock] => Array
(
[table] => uc_product_stock
[num] => 1
[alias] => uc_product_stock
[join] => views_join Object
(
[definition] => Array
(
[left_field] => nid
[field] => nid
[table] => uc_product_stock
[left_table] => node
)
[extra_type] => AND
[table] => uc_product_stock
[left_table] => node
[left_field] => nid
[field] => nid
[type] => LEFT
[adjusted] => 1
)
[relationship] => node
)
[node_data_field_preorder] => Array
(
[table] => node_data_field_preorder
[num] => 1
[alias] => node_data_field_preorder
[join] => views_join Object
(
[definition] => Array
(
[table] => content_type_product
[left_field] => vid
[field] => vid
[left_table] => node
)
[extra_type] => AND
[table] => content_type_product
[left_table] => node
[left_field] => vid
[field] => vid
[type] => LEFT
[adjusted] => 1
)
[relationship] => node
)
[node_counter] => Array
(
[table] => node_counter
[num] => 1
[alias] => node_counter
[join] => views_join Object
(
[definition] => Array
(
[left_field] => nid
[field] => nid
[table] => node_counter
[left_table] => node
)
[extra_type] => AND
[table] => node_counter
[left_table] => node
[left_field] => nid
[field] => nid
[type] => LEFT
[adjusted] => 1
)
[relationship] => node
)
[term_node] => Array
(
[table] => term_node
[num] => 1
[alias] => term_node
[join] => views_join Object
(
[definition] => Array
(
[left_field] => vid
[field] => vid
[table] => term_node
[left_table] => node
)
[extra_type] => AND
[table] => term_node
[left_table] => node
[left_field] => vid
[field] => vid
[type] => INNER////// - desired value
[adjusted] => 1
)
[relationship] => node
)
)//... more stuff here
And if I programmatically add the table within views_query_alter() with:
$view->query->add_table('term_node');
I get the same thing other than 'type' => LEFT:
[term_node] => Array
(
[table] => term_node
[num] => 1
[alias] => term_node
[join] => views_join Object
(
[definition] => Array
(
[left_field] => vid
[field] => vid
[table] => term_node
[left_table] => node
)
[extra_type] => AND
[table] => term_node
[left_table] => node
[left_field] => vid
[field] => vid
[type] => LEFT/////// I can't see how to make this INNER
[adjusted] => 1
)
[relationship] => node
)
Any help much appreciated. There's not much information about this in the API or online.
Comments
Important Message
Please read http://drupal.org/node/644164
Hint: http://drupal.org/project/issues/views?categories=All