Missing "IN" operator in nodereferrer_view_handler_argument.inc
adraskoy - April 24, 2009 - 01:43
| Project: | NodeReferrer |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
When setting up a view with a single argument that was a nodereferrer, an SQL error is generated. The problem is in the query() function in views/nodereferrer_view_handler_argument.inc. I don't entirely understand how the queries are compiled, but it's clear that in the call to $this->query->add_where(), the operator (i.e. $this->options['operator']) is null, as is the group. This means that no operator is given and invalid SQL results. I solved it for my case by checking to see if the operator was null, and setting it to 'in' if so. This may not be the correct general solution.

#1
Can you provide a case when you get this error?
#2
I just upgraded to the latest versions of all modules. Still getting this:
user warning: FUNCTION node.nid does not exist query: SELECT node.nid AS nid, node_node_data_field_day_photo_node_data_field_photo.field_photo_fid AS node_node_data_field_day_photo_node_data_field_photo_field_photo_fid, node_node_data_field_day_photo_node_data_field_photo.field_photo_list AS node_node_data_field_day_photo_node_data_field_photo_field_photo_list, node_node_data_field_day_photo_node_data_field_photo.field_photo_data AS node_node_data_field_day_photo_node_data_field_photo_field_photo_data, node_node_data_field_day_photo.nid AS node_node_data_field_day_photo_nid, node_node_data_field_day_photo.type AS node_node_data_field_day_photo_type, node_node_data_field_day_photo.vid AS node_node_data_field_day_photo_vid, node_data_field_day_number.field_day_number_value AS node_data_field_day_number_field_day_number_value, node.type AS node_type, node.vid AS node_vid, node_data_field_day_number.field_tag_line_value AS node_data_field_day_number_field_tag_line_value, node_revisions.body AS node_revisions_body, node_revisions.format AS node_revisions_format, node_data_field_day_number.field_overnight_value AS node_data_field_day_number_field_overnight_value FROM wild_node node LEFT JOIN wild_content_type_vacation_day node_data_field_day_photo ON node.vid = node_data_field_day_photo.vid LEFT JOIN wild_node node_node_data_field_day_photo ON node_data_field_day_photo.field_day_photo_nid = node_node_data_field_day_photo.nid LEFT JOIN wild_content_type_photo node_node_data_field_day_photo_node_data_field_photo ON node_node_data_field_day_photo.vid = node_node_data_field_day_photo_node_data_field_photo.vid LEFT JOIN wild_content_type_vacation_day node_data_field_day_number ON node.vid = node_data_field_day_number.vid LEFT JOIN wild_node_revisions node_revisions ON node.vid = node_revisions.vid WHERE node.nid (50, 33, 32, 31, 30, 25, 3, 2) ORDER BY node_data_field_day_number_field_day_number_value ASC LIMIT 0, 10 in /home/public_html/dev/sites/all/modules/views/includes/view.inc on line 755.The relevant section is inserted by nodereferrer: WHERE node.nid (50, 33, 32, 31, 30, 25, 3, 2)
as you can see, it should have the word "IN" before the list of node number in parens.
vacation_day is a CCK type with node references field_vacation and field_day_photo referring to CCK types vacation and photo. This view (and the query with the error) shows all the "vacation day" nodes referring to the current vacation node.
There is a related issue, probably around the same part of the code where all vacation days would be retrieved instead of none if there were no referrers.
#3
#4
@adraskoy Are you using 'Operator' "in" or "not in" ?
#5
I'm using Operator: "in". The view has a node for an argument, and I am using nodereferrer here to grab all the nodes that have a node reference to that argument node.
#6
Please try new beta2 which have relation for views
UPDATE: and provide steps to reproduce
#7
The issue is still there. I've been fixing it by adding the following two lines around line 95 of views/nodereferrer_view_handler_argument.inc
else {
$in = '(' . implode(', ', $list) . ')';
> if (!$this->options['operator'])
> $this->options['operator'] = 'in';
$this->query->add_where(
$this->options['group'],
#8
Let's try this patch
Suppose we need more testing maybe this change touching other places