Hi,
anybody can point me to the right way of using the option "Representative view" when adding the relationship "Taxonomy term: Representative node"? What is the correct way of setting up the representative view? I don't really understand the description "Your view must have the ID of its base as its only field"...
What I'm trying to achieve is to make nodes representative when a checkbox is being set to true during the node add/edit process.
If I use this boolean field in the "Representative sort criteria" I get an error message:
Error message
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
If I try to use the "Representative view" option and create a view for that that has the nodeid as the only field, being filtered by the boolean option and has some sorting, I cannot even save the option and get an error message:
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: http://localhost/sites/drupal/admin/structure/views/ajax/config-item/painting_categories/page_1/relationship/tid_representative
StatusText: Internal Server Error
ResponseText:
Thanks for any help!
Comment | File | Size | Author |
---|---|---|---|
#105 | views-representative_view-1417090-105.patch | 4.18 KB | fadi.assaad |
| |||
#82 | views-representative_view-1417090-82.patch | 3.69 KB | prinds |
| |||
#71 | interdiff-1417090-63-71.txt | 1.09 KB | richardbporter |
#71 | views-representative_view-1417090-71.patch | 3.69 KB | richardbporter |
#63 | views-representative_view-1417090-63.patch | 3.68 KB | prinds |
Comments
Comment #1
Codecaster-2 CreditAttribution: Codecaster-2 commentedTry adding it as a filter, but add the nid as the only view field.
Comment #2
drupov CreditAttribution: drupov commentedThanks a lot for your reply, but it still won't work for me.
Here is a snapshot of how my representative view is set up. Sadly the "An AJAX HTTP error occurred..." message still pops up...
Edit: on my windows environment I just saw some more error-message-text (the fonts are smaller vs. ubuntu):
Comment #3
dawehnerUpdate to 7.x-3.x-dev and the error will be gone.
Comment #4
drupov CreditAttribution: drupov commentedSadly not... I even checked this on a clean new drupal site with the same configuration, it's the same error again.
I'm attaching both screenshots from the "master" view (the one that would show the taxonomy terms with one node per term) and the representative view (which is the same as in #2).
Comment #5
Codecaster-2 CreditAttribution: Codecaster-2 commentedThe representative view should return just an ID I think. Instead of using a pager of 10 items, limit the output to 1 element.
Comment #6
drupov CreditAttribution: drupov commentedSorry to keep the issue alive, but I still cannot get it to work (my new view with just one item is attached)...
Am I conceptually wrong? I want to list taxonomy terms and with every term I want to have one node per term (showing a picture field from that node). That should fit?
Should I even try to add a contextual filter to my representative view?
Also I notice that if I use any field on the "Representative sort criteria" option I get above error message:
Comment #7
drupov CreditAttribution: drupov commented@dereine: regarding #3: the patch from http://drupal.org/node/1412734 seems not to be commited to the latest 7.x-3.x-dev version. I applied it manually and great, now the AJAX-error message is gone!
Sadly on my master view I get the error message from #6 (please see attachment), along with a timestamp...
I tried almost everything for my representative view: getting rid of all my filters or using just one filter (e.g. the content published filter), adding a contextual filter for the taxonomy term field (it seems logical to me the master view to pick up the representative nodes for each term by the term id?), setting the output of the representative view to just 1 (although this makes sense only when you use contextual filters...).
Thanks for any help!!!
Comment #8
Countzero CreditAttribution: Countzero commentedSame problem here, not using representative view though, as I don't need complex criteria. Tried both 3.3 and 3.x-dev.
The error disappears if I set the sort criteria to 'nid' instead of the content field I wanted to use in the first place.
This funtionality would be awesome. Is there work done on it already ?
For what it's worth, here is a dump of the resulting query. As expected by the error message, some tokens are not replaced.
Comment #9
Countzero CreditAttribution: Countzero commentedRe-qualifying the issue and updating the relevant version.
Comment #10
Countzero CreditAttribution: Countzero commentedJust in case it rings a bell in some dev's head, here is the query that gets ouput with latest dev :
Something is obviously wrong with some string replacement, so perhaps the problem will jump to the eyes of somebody more versed in Views dev than me ?
Comment #11
dawehnerWhy is this obviously wrong? The inner string is added there by intention.
Maybe this is fixed by #1293980: Groupwise Max Representative View issue
There are multiple issues about that: http://drupal.org/project/issues/views?text=representative it would be cool if you could check them out and see whether some of them fixes your problem.
Comment #12
Countzero CreditAttribution: Countzero commentedObviously, as in : "The 'INNER' strings here and there are obviously breaking the query, and obviously come from a messed up string replacement".
I checked the various issues you indicated before posting, but didn't find anything that seemed relevant to my case. I'll take another tour and update.
Comment #13
druvision CreditAttribution: druvision commentedFor the meanwhile, as noted by dawehner (http://drupal.org/node/1312194#comment-5706918), an alternative solution is to use the views_field_view module.
Comment #14
darrenmothersele CreditAttribution: darrenmothersele commentedI'm getting the same error message (SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens).
It's not the INNER strings that are breaking the query, it's the unbound variables (which in my case look like :db_condition_placeholder_1 etc). I'm been scratching my head about this same issue for a while. I have a representative view that works if I add no filters, no contextual filters, and no relationships. I can start to add filters one by one, and they work, but adding more than one filter breaks everything.
Also, adding the taxonomy term depth filter with a depth of anything other than 0 breaks the view.
Comment #15
SilviuChingaru CreditAttribution: SilviuChingaru commentedIs there a way to get representative node for all children of taxonomy term not just for the term?
For example, if we have a tree like this:
So for example when you want to get representative node for Term1 to get representative node from all Term1 + Term 2 + Term 3 + Term4 like nid4, nid5, nid6, nid7, nid8, nid9, nid10, nid11, nid12, nid13, nid14 or nid15 not just nid4, nid5, nid6???
Comment #16
torvall CreditAttribution: torvall commentedI got the same error described in the OP and found out that checking "Generate subquery each time view is run." the error disappears and the view works.
However, that option's help text says "WARNING: seriously impairs performance", that makes me a bit uneasy. Will enabling the cache for this view work, or will it always force the view to be run to generate the subquery?
Comment #17
philipz CreditAttribution: philipz commentedI'm not sure if this really hepled but I was having the same problem as original
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
What seems to me that helped was adding the field used as "Representative sort criteria" to views sorting. Can someone confirm this?
Comment #18
artbussy CreditAttribution: artbussy commentedConfirm #17 works in my case.
Comment #19
dutchyoda#17 Did not work in my case.
#13 doesn't work for me either, because I need the unrendered, value of the fields.
I'm looking for a solution but I cannot find it. Is there none?
Comment #20
jamix CreditAttribution: jamix commentedUsing the views_field_view module instead of a representative node view (as suggested by druvision in #13) wasn't an option for us because we needed the raw value of nid for further rewriting and template manipulations. So I set out to make representative node views work with filters and sorting enabled.
It turned out that there were three major problems to the current views_handler_relationship_groupwise_max.inc code:
$subquery->getOrderBy()
weren't unaliased into actual field names with table prefixes, which broke the namespacing of the table names:db_condition_placeholder_1
problem)The attached patch addresses all of the three problems. For replacing argument placeholders, I adapted code from
views_ui_preview()
- not sure how secure that approach is. Anyway, my representative node view with extra filters and sorts works now.(To answer questions above, the representative node view should be a simple listing of nodes (with optionally filters and sorts applied), with just the nid field in the field listing. There's no need to add any contextual filters to the view.)
Comment #21
dawehnerThanks for working on that.
No need to wrap this comment such early, there is at least place enough for the "where".
I guess the proper syntax for that is $subquery = clone $subquery;
If we file a patch against drupal core, it seems to make sense to have a helper method for that in dbtng, because this is also used directly in the preview code of the views UI.
Comment #22
jamix CreditAttribution: jamix commentedThanks for the comments. Comment wrapping and
clone
syntax fixed in the attached patch. Not sure how to approach the helper method in dbtng part.Comment #23
stockliasteroid CreditAttribution: stockliasteroid commentedThis patch worked for me...
Comment #24
divined CreditAttribution: divined commentedHunk #1 FAILED at 195.
Hunk #2 FAILED at 269.
Hunk #3 FAILED at 280.
Hunk #4 FAILED at 291.
Comment #25
divined CreditAttribution: divined commentedAfter manual patch:
field_data_field_gorod_sub_global.field_gorod_value = '**CORRELATED**'
This is filter value.
Comment #26
divined CreditAttribution: divined commentedOther values are good.
Comment #27
divined CreditAttribution: divined commentedall contextual filter values return '**CORRELATED**'
Comment #28
jamix CreditAttribution: jamix commented@divined: Are you patching against the latest Views 7.x-3.x-dev?
Comment #29
bmango CreditAttribution: bmango commentedI apologise in advance for this long comment but I'm trying to resolve an issue I've been working on for a while now.
I have been having a problem related to this issue.
I am using panels to display content related to an organic group. On one panel I have several view panes that display taxonomy terms for content associated with the group. Each pane displays terms from a different vocabulary.
I wanted to limit the terms being displayed to only show those terms that a) had Content marked with that term, and b) that content also belonged to the group.
I thought I could achieve this by using the representative node feature. So, for a view pane listings terms for a vocabulary, I added a relationship for representative node with all the defaults.I then added a second relationship for the group membership based on the representative node. Finally I added a context for the group based on the group membership relationship and having the group ID passed through the panel context.
This worked well for vocabularies which only applied to a single content type. However, for vocabularies which applied to more than one content type it wasn't working. I thought maybe the answer was to use a representative view (Is this right? To limit the representative nodes to one content type only?). So I created a new view to display only the ID for one content type and with a sort, and used this as the representative view.
When I did this I got the error:
Notice: Undefined offset: 1 in views_handler_relationship_groupwise_max->left_query() (line 274 of .../sites/all/modules/views/handlers/views_handler_relationship_groupwise_max.inc).
So I updated the views module to the latest dev version and applied the patch at #22 (incidentally, I had to apply the patch manually as it didn't seem to work for me using cygwin).
This did make a difference but the view still wasn't showing all the terms that it should have been showing.
I guess my question is, can the representative view work in this way: to limit terms to select from just one content type? If it doesn't could anyone possibly suggest to me how I might be able to limit terms to only show when they have content associated with them and where that content also belongs to the group defined by the context, for vocabularies that apply to more than one content type?
At the moment, I'm not sure if I'm simply using this feature in the wrong way or if there is an actual bug :\
Comment #30
bmango CreditAttribution: bmango commentedOkay, apologies, this is not really to do with the issue, but I managed to get the results I was looking for (#29) by using a different kind of view. I created a term view and added a relationship for "content with term", and a second relationship for "group membership" based on the first relationship. I then added in a filter for the content type, and a context filter for the group. I only added a field for the term and in the query settings made the query distinct. The view now only shows terms which relate to content of a specific type and that [the content] belong to a specific group. It works great :)
Comment #31
Summit CreditAttribution: Summit commentedHi @bmango, can you export your view please?
Thanks a lot in advance for your reply!
Greetings, Martijn
Comment #32
bmango CreditAttribution: bmango commentedHi @Summit, I'm uploading my view here. Let me know if you need anything else.
Since yesterday I've found that I've also been having problems with my views using representative node for taxonomy vocabularies that apply to only one content type. So have replaced these as well with the solution I worked out in #30.
Comment #33
13rac1 CreditAttribution: 13rac1 commentedIgnoring #29-32. The comments have nothing to do with the original issue. @bmango please open a separate issue for your question.
The patch in#22 applies cleanly to the current Views 3.x dev and corrects the described issue. Thank you @jamix!
Comment #34
13rac1 CreditAttribution: 13rac1 commentedI set #1590264: Unknown column 'taxonomy_term_data.tid' in 'where clause' as a duplicate to this issue. It's not exactly a duplicate, but the IMO ideal fix for it requires modification to the patch in #22 and they are quite related.
The issue is in a View with multiple displays the argument sub-querys are generated in the same PHP call incrementing the static placeholder counter resulting in SQL errors:
The SQL column name shouldn't have the number 1 at the end. Further details in: https://drupal.org/node/1590264#comment-7855877
I've added the correction into jamix's patch. The original Views placeholder replacement code is removed. Jamix's subquery argument placeholder replacement foreach() gets a new elseif to change the **CORRELATED** string to the value of $this->definition['outer field'].
Relevant changes:
Comment #35
13rac1 CreditAttribution: 13rac1 commentedBah.. Bad wording in comment. Fixed.
Comment #36
Elin Yordanov CreditAttribution: Elin Yordanov commented#35: representative_views-1417090-35.patch queued for re-testing.
Comment #37
askibinski CreditAttribution: askibinski commentedThanks!
I was coming from the issue #1454588: Relationship: User: Representative node bug? and the patch at #36 solved it. Great stuff!
Comment #38
13rac1 CreditAttribution: 13rac1 commentedI just set #1454588: Relationship: User: Representative node bug? as a duplicate of this issue. Please RTBC if everything looks good. Jamix and I cannot since we've both worked on the patch directly.
Comment #39
Jcke CreditAttribution: Jcke commentedHad this problem with a view based on user profile values and in need of advanced sorting of nodes through relationships - representative views. This patch seems to have solved the issue. I am very grateful, great work guys!
Comment #40
paboden CreditAttribution: paboden commented#35 Worked for me, Thanks!
Comment #41
mpark CreditAttribution: mpark commented#35 Worked, thank you so much!
Comment #42
dadderley CreditAttribution: dadderley commentedHad the same problem.
#35 Worked for me as well.
Thank you.
Comment #43
philipz CreditAttribution: philipz commentedI've applied patch #35.
Although I'm not getting any errors I'm not seeing corect results as well. I have a silmple view for my taxonomy terms and I'm trying to display an image for representative node of each term.
Some of the terms have their representative fetched and some of them not and I'm not even looking at the representative sorting right now!
Please what is the simplest setup this should work for? Maybe if I start from scratch something will work eventually :)
Comment #44
jason.fisher CreditAttribution: jason.fisher commentedPatched worked here with the latest dev.
Comment #45
dillix CreditAttribution: dillix commentedThanks, eosrei! #35 works well, +1 for RTBC
Comment #46
drupalerocant CreditAttribution: drupalerocant commentedFor me it works perfect as well.
Thank you very much!
+1 to RTBC!
Comment #47
dadderley CreditAttribution: dadderley commentedThe patch at at #35 was not incorporated into the the 3.7 release.
But it has been incorporated into the 3.8 release and the issue has been resolved for me.
Thanks
Comment #48
dadderley CreditAttribution: dadderley commentedThe issue that I had was the same as the one @ Relationship: User: Representative node bug?
Comment #49
PMorris CreditAttribution: PMorris commentedI still have the issue even with the lastest 7.x-3.8 release. Dev version 7.x-3.7+37-dev didn't fix error either.
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_term_data.tid2' in 'where clause'
Patch #35 is the only thing that fixes it for me.
Comment #50
shadysamir CreditAttribution: shadysamir commentedI confirm that this still exists in 7.x-3.7+37-dev and it requires patching with #35 to work
Comment #51
Chris Gillis CreditAttribution: Chris Gillis commentedDoes not work for me. I'm trying to list a "profile node" for each user.
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
Comment #52
13rac1 CreditAttribution: 13rac1 commentedNote: This issue also exists in D8 core. I'm going to write a patch for D8, perhaps it will get this patch committed too.
Comment #53
13rac1 CreditAttribution: 13rac1 commentedI found a problem with my patch in #35 while writing the D8 core views patch for this issue. The following error is generated if the Representative View contains a Views Query Substitution, such as the current time for the content last updated date:
For reference, some example View Query Substitutions: https://api.drupal.org/api/views/views.api.php/function/hook_views_query...
The attached patch now includes a call to views_query_views_alter() to run the substitution.
Comment #54
13rac1 CreditAttribution: 13rac1 commentedComment #55
chrisfromredfinI've re-applied this patch against 7.x-3.x dev and anecdotally it seems to still be working, though the testbot is stalled.
Comment #56
MrPeanut CreditAttribution: MrPeanut commentedPatch in #35 works for me except when using a random sort (#2225969: View Taxonomy term "Representative node" with global random ).
Comment #57
xjmIt would be good to test and see if this same bug exists on D8, as we will need to fix it in core too in that case (and looking at all the prayerful comments in this handler, I wouldn't be surprised). A quick(er) way to test might be on http://simplytest.me/.Edit: Just saw that it does in #52, sorry! Thanks for #2379423: Representative Node Views fails due to invalid SQL.
Comment #59
xjmSo something is wrong with the Views branch tests: https://www.drupal.org/node/38878/qa
Comment #60
askibinski CreditAttribution: askibinski commentedI can confirm patch at #53 works with views 3.10.
Comment #61
dadderley CreditAttribution: dadderley commented@askibinski
Same here.
I can confirm patch at #53 works with views 3.10.
Comment #62
54rigger CreditAttribution: 54rigger commentedPatched views to solve this problem, and my site is working as it should, however
this query is running and timing out on Mysql server, after 24hrs on a site with no traffic, MYsql grinds to a halt and the site won't respond.
-- Connection Id: 11402
-- User: **********
-- Host: localhost
-- DB: **********
-- Command: Query
-- Time: 1509
-- State: statistics
SELECT COUNT(*) AS expression
FROM
(SELECT DISTINCT node.nid AS nid, node.title AS node_title, node.language AS node_language, 'node' AS field_data_field_image_node_entity_type, 'node' AS field_data_field_summary_node_entity_type, 1 AS expression
FROM
node node
LEFT JOIN (SELECT td.*, tn.nid AS nid
FROM
taxonomy_term_data td
LEFT JOIN taxonomy_vocabulary tv ON td.vid = tv.vid
LEFT JOIN taxonomy_index tn ON tn.tid = td.tid
WHERE (tv.machine_name IN ('applications', 'features', 'products', 'substrates')) AND (td.language IN ('en', 'und')) ) taxonomy_term_data_node ON node.nid = taxonomy_term_data_node.nid
INNER JOIN taxonomy_index taxonomy_index_value_0 ON node.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_0.tid = '52'
INNER JOIN taxonomy_index taxonomy_index_value_1 ON node.nid = taxonomy_index_value_1.nid AND taxonomy_index_value_1.tid = '4'
INNER JOIN taxonomy_index taxonomy_index_value_2 ON node.nid = taxonomy_index_value_2.nid AND taxonomy_index_value_2.tid = '41'
INNER JOIN taxonomy_index taxonomy_index_value_3 ON node.nid = taxonomy_index_value_3.nid AND taxonomy_index_value_3.tid = '38'
INNER JOIN taxonomy_index taxonomy_index_value_4 ON node.nid = taxonomy_index_value_4.nid AND taxonomy_index_value_4.tid = '33'
INNER JOIN taxonomy_index taxonomy_index_value_5 ON node.nid = taxonomy_index_value_5.nid AND taxonomy_index_value_5.tid = '7'
INNER JOIN taxonomy_index taxonomy_index_value_6 ON node.nid = taxonomy_index_value_6.nid AND taxonomy_index_value_6.tid = '5'
INNER JOIN taxonomy_index taxonomy_index_value_7 ON node.nid = taxonomy_index_value_7.nid AND taxonomy_index_value_7.tid = '6'
INNER JOIN taxonomy_index taxonomy_index_value_8 ON node.nid = taxonomy_index_value_8.nid AND taxonomy_index_value_8.tid = '77'
INNER JOIN taxonomy_index taxonomy_index_value_9 ON node.nid = taxonomy_index_value_9.nid AND taxonomy_index_value_9.tid = '123'
INNER JOIN taxonomy_index taxonomy_index_value_10 ON node.nid = taxonomy_index_value_10.nid AND taxonomy_index_value_10.tid = '36'
WHERE ((( (taxonomy_index_value_0.tid = '52') AND (taxonomy_index_value_1.tid = '4') AND (taxonomy_index_value_2.tid = '41') AND (taxonomy_index_value_3.tid = '38') AND (taxonomy_index_value_4.tid = '33') AND (taxonomy_index_value_5.tid = '7') AND (taxonomy_index_value_6.tid = '5') AND (taxonomy_index_value_7.tid = '6') AND (taxonomy_index_value_8.tid = '77') AND (taxonomy_index_value_9.tid = '123') AND (taxonomy_index_value_10.tid = '36') ))AND(( (node.status = '1') AND (node.type IN ('portfolio')) AND (node.language IN ('en')) )))) subquery
Comment #63
prinds CreditAttribution: prinds commentedThe patch in #53 didn't work for me.
The sort by fields of the representative view was unintentionally removed by the foreach on line 267. When the de-aliased fields are added to the $order array, they also get processed in the foreach. This fails since it can't find the table and field without the original alias, and then the unset function removes the de-aliased order fields.
I don't know why that didn't happen to askibinski and dadderley, but I guess it could be different versions of php that handles the foreach in different ways. But in any case it's not a good idea to mess with the array while inside the foreach.
I have made a new version of the patch in #53 that uses a temporary array instead and that works for me.
Comment #64
markbannister CreditAttribution: markbannister commented#63 seemed to clear it up for me so far.
Comment #65
drupalerocant CreditAttribution: drupalerocant commentedThank you form the patch #63 worked for me also.
Comment #66
evilfurryone CreditAttribution: evilfurryone at Wunder commentedCan confirm #63 worked for me too.
Does anyone know why is the testing in postponed status? Would be nice to have this into dev branch. Can we maybe poke the test to restart and maybe succesfully run?
Comment #67
dadderley CreditAttribution: dadderley as a volunteer commentedHi prinds,
Applied your patch to Views 7.11. It works very well for my use case.
Thank you
Comment #68
fonant CreditAttribution: fonant at Fonant Ltd commentedPatch in #63 worked here to fix a "represenative node" query generation problem for a users view.
Comment #69
prinds CreditAttribution: prinds commentedI don't know why the test request was postponed, but based on your feedback, I suggest we say the bug is fixed with #63 and hopefully we can get this committed soon?.
Thanks for your feedback..
Comment #70
petria CreditAttribution: petria commentedCan confirm #63 worked for me too.
I vote for fixed status too.
Comment #71
richardbporter CreditAttribution: richardbporter as a volunteer commentedThe patch in #63 worked for me as well. I re-rolled with a few minor coding standard fixes. Maybe this will successfully trigger the testbot.
Comment #72
richardbporter CreditAttribution: richardbporter as a volunteer commentedComment #73
goldlilys CreditAttribution: goldlilys as a volunteer commented#63 for Views 7.x-3.11 worked for me too.
Comment #74
agentrickardNew patch tests correctly with Drupal 7.39
Comment #75
d1v9d CreditAttribution: d1v9d as a volunteer commentedThe patch worked for me. Thank you.
Comment #76
richardbporter CreditAttribution: richardbporter as a volunteer commentedI don't think the tests will run until the 7.x-3.x branch tests pass: https://qa.drupal.org/pifr/test/27332
Comment #77
mikedotexe CreditAttribution: mikedotexe at Metal Toad commented#71 worked for me. Thanks to everyone involved.
Comment #78
millionleaves CreditAttribution: millionleaves as a volunteer commented#71 plus a cache clear also worked for me - thanks.
Comment #79
colanAttempting to trigger the new testbot now that all tests are passing on the branch.
Comment #80
colanComment #81
colanWe've recently switched our testing from the old qa.drupal.org to DrupalCI. Because of a bug in the new system, #2623840: Views (D7) patches not being tested, older patches must be re-uploaded. On re-uploading the patch, please set the status to "Needs Review" so that the test bot will add it to its queue.
If all tests pass, change the Status back to "Reviewed & tested by the community". We'll most likely commit the patch immediately without having to go through another round of peer review.
We apologize for the trouble, and appreciate your patience.
Comment #82
prinds CreditAttribution: prinds commentedHere's the re-rolled patch from #71
Let's hope it goes through..
Comment #83
bmango CreditAttribution: bmango commentedPatch in #82 works well for me. Thank you :)
Comment #84
prinds CreditAttribution: prinds commentedThe test passed and we've got positive response.. Please note, that the patch in #82 and #71 are identical, so I'd say this is tested.
Hopefully this can be committed soon.
Comment #85
bmango CreditAttribution: bmango commentedI'm not sure of the right protocol here but would it be possible to combine the patch here with the patch supplied for the issue SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.uid1' in 'where clause'?
The patch in this issue and the other issue both apply to the same file: /handlers/views_handler_relationship_groupwise_max.inc, and so it is not possible to apply them both. The second patch is quite small and so I thought it would be easier to incorporate it in the patch here. I have had a look at the code and it seems to me it would be possible to combine them by replacing lines 67-69 (of this patch):
with
However, I'm not a coder and don't want to mess anything up. All credit to nvahalik for the code from his patch I used here.
The reason I ask is because I have a view using a representative node relationship which is itself based on another relationship and so both the issues are coming up.
Apologies if I should be raising this in a separate issue...
Comment #86
bmango CreditAttribution: bmango commentedPlease ignore my comment in #85. It is impractical to try and solve another issue here. Let's wait for this patch to be committed, and then the code can be adjusted in the other patch.
Comment #87
bmunslow CreditAttribution: bmunslow at SOCIETAT PORTAL DE LLEIDA S.L commentedHi, I would like to report the following issue with patch #82.
If the representative node is selected by means of a representative subquery view which applies a RANDOM sort, the resulting view fails with the following MySQL error:
SQLSTATE[42000]: Syntax error or access violation: 1064 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 'INNER. ASC LIMIT 1 OFFSET 0) = node_users.nid LEFT JOIN ...' at line 3
Reviewing the query, there is indeed a MySQL error in the query:
ORDER BY INNER. ASC
Setting issue back to 'Needs work' for the moment.
Comment #88
bmunslow CreditAttribution: bmunslow at SOCIETAT PORTAL DE LLEIDA S.L commentedSwitching back to RTBC, since the issue reported in #87 might be considered a separate issue by itself.
Comment #89
Lanny Heidbreder CreditAttribution: Lanny Heidbreder at Stone Ward commented#82 solved the problem I had getting my new feature at https://www.drupal.org/node/2728673 to work. My patch there includes the code from #82, but I'll reroll it with only my changes if this one gets committed.
Comment #90
millionleaves CreditAttribution: millionleaves as a volunteer commented#82 works on the latest version of Views for me. Would be good to see it committed...
Comment #91
balapalanisamy CreditAttribution: balapalanisamy as a volunteer and commentedConfirming that #82 is working for me as well
Comment #92
IckZ CreditAttribution: IckZ commentedConfirming #82 - great work thanks!
Comment #93
fonant CreditAttribution: fonant commentedPatch #82 works with the current dev version here.
Comment #94
gerson.analista CreditAttribution: gerson.analista as a volunteer commentedConfirming that #82 is working here (version 7.x-3.14).
Comment #95
Summit CreditAttribution: Summit commentedPlease add patch #82 to module dev. Thanks a lot in advance!
Greetings, Martijn
Comment #96
dadderley CreditAttribution: dadderley as a volunteer commented@gerson.analist
Same here.
Confirming that #82 is working here (version 7.x-3.14)
Comment #97
RAWDESK CreditAttribution: RAWDESK for Colruyt Group Services commentedSame result. Patch #82 is working
Comment #98
colanIs this also a problem in Drupal 8? If so, we should open a ticket there before committing this.
Comment #99
donapis CreditAttribution: donapis commentedHi,
Patch #82 not working for the latest views (Views-7.x-3.16).
Comment #100
13rac1 CreditAttribution: 13rac1 as a volunteer commented@colan I created #2379423: Representative Node Views fails due to invalid SQL for D8 2.5 years ago.
Comment #101
colanThanks.
Comment #102
x.meglio@gmail.com CreditAttribution: x.meglio@gmail.com commentedDear community, the issue in 8.x has been not touched for 2 years. Does it mean there is some patch working for 8.x, or is it just that there is no obvious solution to the issue?
"Representative node" feature is a core feature, and it covers many various cases. What can we do to get a patch for 8.x, especially latest 8.4?
Comment #103
NWOM CreditAttribution: NWOM commented@x.meglio@gmail.com: This issue is for Drupal 7. I think you meant to post in this issue: #2379423: Representative Node Views fails due to invalid SQL.
Comment #104
doostinharrell CreditAttribution: doostinharrell as a volunteer and commentedI can also vouch for patch #82. Filtering via "Representative View" is now working for me :D
Comment #105
fadi.assaad CreditAttribution: fadi.assaad commentedHere's the re-rolled patch from #82, now its compatible with commit 22622c95760dffdcda8d3b64b032298184eaa66c
Comment #107
DamienMcKennaCommitted. Thanks everyone.
Comment #109
nvahalik CreditAttribution: nvahalik at Code and Salt commentedLooks like the inclusion of this patch (7.x-3.19) has caused a regression in the work done on #2295379: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.uid1' in 'where clause' (7.x-3.16). The patch in the latter ticket was committed March 29th and this patch was re-rolled 3 days later without what appears to be any additional checking to ensure that it would work. Can we get this patch reverted and re-rolled properly to not clobber the changes in #2295379: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.uid1' in 'where clause'?
Comment #110
hip CreditAttribution: hip commentedSame here. Sorting not working (I want the latest nodes but only showing the oldest ones). Last D7 stable version so far.
Isn't it possible to reopen the issue? Thank you.
UPDATE: cloning the view did work. In case it may help.
Comment #111
NWOM CreditAttribution: NWOM commentedI recommend starting a new issue. A lot of the times, commited (fixed) issues get overlooked, since they are already closed. If it has been committed, it generally warrants a new issue.