I have set up a View for a node type = Projects
Projects have two different userreference CCK fields: Project Leader and Project Chair
I'm trying to create a view that can be used in Panels as a *user* landing page.
So, this view wants to use the UID of the user as an argument to find references to Project Leader OR Chair
This module looks like it will do the job...
I inserted 3 views_or elements between my 2 arguments:
alternative start
- project_chair
alternative next
- project_leader
alternative end
But on save/previewe, I get a block of SQL warnings:
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 18 query: SELECT DISTINCT(node.nid) AS nid, node_data_field_program_uid.field_program_uid_value AS node_data_field_program_uid_field_program_uid_value, node.type AS node_type, node.vid AS node_vid, node_data_field_proj_uid.field_proj_uid_value AS node_data_field_proj_uid_field_proj_uid_value, node.title AS node_title, node_data_field_program_uid.field_project_status_value AS node_data_field_program_uid_field_project_status_value, node_data_field_project_leader.field_project_leader_uid AS node_data_field_project_leader_field_project_leader_uid, node_data_field_project_chair.field_project_chair_uid AS node_data_field_project_chair_field_project_chair_uid FROM node node LEFT JOIN content_field_project_leader node_data_field_project_leader ON node.vid = node_data_field_project_leader.vid LEFT JOIN users users_node_data_field_project_leader ON node_data_field_project_leader.field_project_leader_uid = users_node_data_field_project_leader.uid LEFT JOIN content_type_project node_data_field_reportbuilder_ref ON node.vid = node_data_field_reportbuilder_ref.vid LEFT JOIN node node_node_data_field_reportbuilder_ref ON node_data_field_reportbuilder_ref.field_reportbuilder_ref_nid = node_node_data_field_reportbuilder_ref.nid LEFT JOIN content_type_project node_data_field_program_uid ON node.vid = node_data_field_program_uid.vid LEFT JOIN content_field_proj_uid node_data_field_proj_uid ON node.vid = node_data_field_proj_uid.vid LEFT JOIN content_field_project_chair node_data_field_project_chair ON node.vid = node_data_field_project_chair.vid WHERE
in /home/railcrc/prod/htdocs/drupal/sites/all/modules/contrib/views/includes/view.inc on line 759.
Notice the truncation at WHERE above...?
And strangely, this actually does its job when we are viewing the user's node (ie, the OR filtering works).
What is going on with all the warnings?
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | views_or_default_arguments.patch | 2.37 KB | skylord |
Comments
Comment #1
raintonr commentedI'm seeing this problem too. However, the view doesn't work at all (and why would it if the 'WHERE' clause is missing?).
FWIW what I'm doing is a little complicated. Am building a sports fixtures database. There are 2 node references in a fixture, the home (side A below) and away (side B) sides. I'd like to build a view that shows all the fixtures for a team.
Using relationships I can easily show all the home games, or all the away games separately by using the team name as an argument and a relation ship to either 'home' or 'away' in the fixture. However, when I try and combine these the error occurs:
This is the SQL generated in views preview:
And here's the view exported:
Comment #2
itangalo commentedI got the same result, but the problems resolved nicely when I unchecked the option "show all" on argument not present. My guess is that Views gets confused if one of the arguments says "hide view if no argument is present" while the other says "show everything if no argument is present".
Please confirm if the same thing helps for you.
//Johan Falk, [NodeOne](http://nodeone.se), [Sweden](http://drupalsverige.se)
Comment #3
drupup commentedI'm trying to set up a similar View, with home and away team. If you got yours to work correctly, can you describe exactly how you set up the View to make it work? I'm frustrated so far.
Comment #4
jwarner commentedRe: #2, the same workaround resolves the error for me, as well. Thanks for the information.
Comment #5
faridjame commented@Itangalo, When you unchecked the "show all" option, what other option did you select instead?
Comment #6
itangalo commented@drupup and @farjam60: Sorry for responding so late. I am not 100 percent sure after all this time, but a qualified guess is that I set all arguments to "hide view if no argument is present".
Comment #7
arithmetric commentedThis issue may be related to #396094: exposed filters generate error. Could someone test the patch I posted there:
http://drupal.org/node/396094#comment-3742482
The related issue is about exposed filters instead of arguments, and I've only tested the filter-related fix, but included in the patch a similar change to the argument handler.
If that patch fixes this issue, then let's close this as a duplicate.
Comment #8
skylord commentedAs i see this problem consists of two parts:
1) Views behaviour when it stops arguments processing if argument is invalid.
2) Views_or behaviour when it removes all "where" conditions at "begin alternatives" phase and restores them at "end alternatives".
So, it Views stops arguments processing (look at "view::_build_arguments") - we get empty "where"....
Here is my rough and dirty patch to deal with such situation. Works fine for me - my views now support "show all" options as no_argument or invalid_argument rollback.
Comment #9
henrijs.seso commentedPatch #6 over at #396094: exposed filters generate error fixed errors and looks cleaner than one at #8 here, but I am not sure if both of them are doing the same, so Im not gona make this duplicate.
Comment #10
skylord commentedI tried #6 from #396094: exposed filters generate error and it didn't help me. Actually it doesn't deal with "show all" rollback of bad argument. The key is that end_alternatives query method is not executed in this case and it has no sense to make any changes there... At begin_alternatives stage query must be ready to execute in case of future stopping next arguments processing by view::_build_arguments
I'll be very happy to see cleaner solution than mine - ready for tests.
Comment #11
henrijs.seso commented#8 made my view display nodes instead of fields, smallprint is "Works fine for me" ;)
Comment #12
skylord commentedHm. It's strange - #8 doesn't touch any display options - only "where" part of query. Can you post your view export (maybe to PM, not here)?
Comment #13
henrijs.seso commentedyes, it was my misconfiguration, sorry