I have a calendar view that displays a cck content type. Yesterday I updated to the latest RCs of cck,views,date,calendar and I'm now getting an error in the log whenever the calendar page is viewed. It doesn't seem to affect the functionality of the calendar.

Other views don't seem to have a problem.

Unknown column 'node_data_field_date_field_date_value' in 'order clause' query: SELECT node.type AS node_type FROM node node LEFT JOIN content_type_seminar node_data_field_date ON node.vid = node_data_field_date.vid LEFT JOIN content_type_event node_data_field_date_time ON node.vid = node_data_field_date_time.vid WHERE 0 ORDER BY node_data_field_date_field_date_value ASC, node_data_field_date_time_field_date_time_value ASC in /var/www/sites/all/modules/views/includes/view.inc on line 715.

Comments

karens’s picture

Status: Active » Fixed

Update to the latest -dev version of everything or wait for my next release, which will be in the next couple of days. This problem has already been addressed there.

demeester_roel’s picture

Version: 6.x-2.0-rc3 » 6.x-2.x-dev
Status: Fixed » Active

I'm using the latest dev version (oct-11th) of date module. - 6.x-2.x-dev
I'm using the latest dev version (oct-10th) of views module - 6.x-2.x-dev

The issue is still (or again) active.

In my case the the constructed (erroneuous) SQLcode was

SELECT node.type AS node_type FROM node node LEFT JOIN
content_field_activiteit_date node_data_field_activiteit_date ON
node.vid = node_data_field_activiteit_date.vid WHERE 0
ORDER BY node_data_field_activiteit_date_field_activiteit_date_value ASC

The correct SQL should be

SELECT node.type AS node_type FROM node node LEFT JOIN
content_field_activiteit_date node_data_field_activiteit_date ON
node.vid = node_data_field_activiteit_date.vid WHERE 0
ORDER BY node_data_field_activiteit_date.field_activiteit_date_value ASC

I've been investigating both views and date for an hour hoping to find a fix, but the closest i could get was that in query.inc (views) around line 772 (add_orderby function) an incorrect alias is generated. Iso using $table.'.'.$field the query is build using $table.'_'.$field.
I'm guessing that in this case, the date module should have intercepted this cck field and generate a correct orderby statement instead.

karens’s picture

Status: Active » Fixed

You're incorrect about the problem and the fix. Views creates the sort and uses the alias (with an underscore) to create it. The problem with the query is not that part, but that the sort field should be added to the select list.

This problem comes up only in a very specific situation -- when you add a multiple value field to a view and use the option to 'group' multiple values, then add that same multiple value field as a sort. In that case the field will not get added to the select list as it should because CCK's handler for the grouped value removes the field from the query, and you will get this error.

There is supposed to be some validation in the view to force you not to use 'group' option on date fields. You can't 'group' date fields in the calendar anyway, they won't work right since each one needs to be shown as a separate item in the calendar. Until I get the validation in there to force you to do this right just edit the date field in the view and uncheck the option to 'group' multiple values.

karens’s picture

I'm committing a fix to add that validation, which needs to be done, but after doing that I spent a lot of time trying to create any situation where you could add a multiple value sort to the view without the field being added to the select and couldn't find a way to do it. I couldn't come up with any way to replicate your error.

Anyway, I'm adding the validation and you should uncheck the option to group multiple values.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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