Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
This is essentially the reverse of the bug fixed in http://drupal.org/node/1904622.
If you're using multiple entity types as groups, the "@entity from OG membership" and "Group @entity from OG membership" views relationships will return errorious data.
For "@entity from OG membership", the view query is:
SELECT ...
FROM
{og_membership} og_membership
LEFT JOIN groupentity ON og_membership.gid = groupentity.id
but needs to be:
SELECT ...
FROM
{og_membership} og_membership
LEFT JOIN groupentity ON og_membership.gid = groupentity.id AND og_membership.entity_type = 'groupentity'
And for "Group @entity from OG membership", the view query is:
SELECT ...
FROM
{og_membership} og_membership
LEFT JOIN groupentity ON og_membership.gid = groupentity.id
but needs to be:
SELECT ...
FROM
{og_membership} og_membership
LEFT JOIN groupentity ON og_membership.gid = groupentity.id AND og_membership.group_type = 'groupentity'
Thanks
Comments
Comment #1
spotzero CreditAttribution: spotzero commentedThe attached patch adds the required relationship handlers to handle these cases.
Thanks.
Comment #2
amitaibuCorrect status for testbot to run.
Comment #3
amitaibuWe probably don't need 2 handlers for this -- can't we have only a single one, that changes the
field
according to some property we pass in the data array?Comment #4
spotzero CreditAttribution: spotzero commentedDefinitely. Just let me write it and I'll roll you a patch.
Comment #5
spotzero CreditAttribution: spotzero commentedI've reduced all of the views relationship handlers into one more intelligent handler.
This relationship handler handles the og_membership table being in either the right or left positions of the join, as well as including options for filtering the join by the group_type, entity_type, or both.
Its behaviour is definited by the relationship definition in og_views_data_alter().
Comment #6
amitaibuGetting very close :) Nit picks:
Extra space.
End line with dot.
Comments should be up to the 80 chars margin, per line.
Extra space
Shouldn't be
elseif
?Comment #7
spotzero CreditAttribution: spotzero commentedThe attached patchfixed the various issues, except for the last one.
The second 'if' is not an 'elseif' so that this relationship handler has the option of filtering joins by both entity_type and group_type.
Honestly, I don't have a use-case for this behaviour, but it's valid, so there could be one. This may be functionality that will never be used, but it shouldn't break anything.
Comment #8
amitaibuRemember to set correct status for testbot :)
Comment #9
amitaibuCommitted, thanks.