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.

CommentFileSizeAuthor
#8 443444_in.patch854 bytesandypost

Comments

andypost’s picture

Status: Active » Postponed (maintainer needs more info)

Can you provide a case when you get this error?

adraskoy’s picture

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.

adraskoy’s picture

Status: Postponed (maintainer needs more info) » Active
andypost’s picture

@adraskoy Are you using 'Operator' "in" or "not in" ?

adraskoy’s picture

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.

andypost’s picture

Please try new beta2 which have relation for views

UPDATE: and provide steps to reproduce

adraskoy’s picture

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'],
andypost’s picture

Status: Active » Needs review
StatusFileSize
new854 bytes

Let's try this patch
Suppose we need more testing maybe this change touching other places

andypost’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.