Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be very useful for to have a GROUP_CONCAT available as an aggregate function. like what we have now e.g. SUM, MIN, ...
Comment | File | Size | Author |
---|---|---|---|
#33 | add_group_concat_aggregate-2902481-33.patch | 12.96 KB | navkaur |
#31 | 2902481-31.patch | 12.97 KB | KapilV |
#30 | add_group_concat_aggregate-2902481-30.patch | 12.87 KB | jackson.cooper |
#29 | interdiff_28_29.txt | 5.42 KB | KapilV |
#29 | 2902481-29.patch | 11.82 KB | KapilV |
Comments
Comment #2
david_garcia CreditAttribution: david_garcia commentedGROUP_CONCAT is not part of the SQL ANSI standard so it will limit portability of the feature.
This should be dealt with in contrib.
Comment #3
b.ravanbakhshHere's the patch.
Works for me.
Try it with a view of nodes grouped on uid and GROUP_CONCAT on nid or title.
Comment #4
joachim CreditAttribution: joachim commentedIIRC there is already an issue for this.
Comment #5
b.ravanbakhsh@david_garcia have not seen your comment before post patch.
As I know PostgreSQL does not have group_concat but has "array_agg" so we can not fix that.
Comment #7
Sir-Arturio CreditAttribution: Sir-Arturio at Druid commentedThe patch fails for me (for 8.4.x). I think it's missing ']' character.
Also I'd like to point out that group_concat is used for other fields than just numeric. Changing
'field' => 'numeric'
to'field' => 'field'
enables concatenation of textual fields as well.There are already some issues (like the one I linked as related) but no real fixes. Some recommend using the contrib module Views Aggregator Plus but does not solve the problem for me. It introduces a whole new paradigm for views which has it's own problems.
Comment #8
Sir-Arturio CreditAttribution: Sir-Arturio at Druid commentedHere is my crude patch of how I got the group concat to work.
Comment #10
kasperg CreditAttribution: kasperg at Reload commentedThe patch does not apply using patch level p2. Here is an updated one that does.
The change might be crude, not portable and lacking features such as the ability to define separators and the like, but for a simple case it has worked well for me.
Comment #11
kasperg CreditAttribution: kasperg at Reload commentedPatch in #10 does not apply either. This should work.
Comment #12
achtonHere is the patch from #11 rerolled for Drupal 8.6.1.
Comment #13
m.lebedev CreditAttribution: m.lebedev commentedIt works. thanks
Comment #14
PanchoNew features go into the latest dev branch. Also unassigned after 18 months.
Comment #15
SimeonKesmev CreditAttribution: SimeonKesmev commentedThe field argument for the handler shall not be "field" as it tries to load it from the entity object. I am having problem when trying to actually output it.
Here is an updated patch.
Comment #16
gambryThis needs tests.
Comment #17
attisantested #15 patch and found
Comment #18
BeakerboyWouldn’t the addition of GROUP_CONCAT to Core limit it’s installation on non MySQL databases?
Comment #20
brooke_heaton CreditAttribution: brooke_heaton as a volunteer commentedPatch #17 is working well for me. I would however love to see some more settings on this Filter Plugin - specifically to allow the substitution of a separator (e.g. not a comma) also there is no space between records. Allowing a unique separator would fix that. I'm wondering why this does not allow the use of token/twig replacements. Maybe that's too much to task.
Comment #21
codesmithPatch in #17 works great for me - thanks!
Comment #23
mellowtothemax CreditAttribution: mellowtothemax commented#17 works for me too,
but it only returns ID values.The formatting options are removed from the field.This would be great to add as well as what #20 suggested.
This works with data export which is a bonus as its needed for xml feeds for commerce.
Correction. The ID value only returned on commerce variation attributes. With the correct relationship fields it works correctly.
Comment #25
petednz CreditAttribution: petednz commentedPatch has solved our problems too. thank you. we used "rewrite" and {{ |replace({',': "
"})|raw}} to get each value on to its own line. assuming same could be done if someone wanted to replace 'comma' with 'comma space'
Comment #26
petednz CreditAttribution: petednz commentedComment #27
daffie CreditAttribution: daffie commented@petednz: We need to add testing for the added functionality. First to test if the added functionality does what it is supposed to and second to make sure that it keep working and that some future update does not break the added functionality.
Comment #28
jackson.cooper CreditAttribution: jackson.cooper as a volunteer commentedHere's patch #17 that fixes the PHP 7.4 deprecation notice and some linting errors.
Comment #29
KapilV CreditAttribution: KapilV as a volunteer and at Innoraft for Drupal Care, Drupal Association commentedFixed PHPCss error.
Comment #30
jackson.cooper CreditAttribution: jackson.cooper as a volunteer commentedThe original patch was missing some code. I've added it back and included the changes in #29.
Comment #31
KapilV CreditAttribution: KapilV as a volunteer and at Innoraft for Drupal Care, Drupal Association commentedComment #33
navkaur CreditAttribution: navkaur commentedThe above patch wasn't applying to core version 9.2.2 and above.
Its minor change which removes the space from the comment line
// https://www.drupal.org/node/571548.
to make it compatible with latest version.Comment #36
Adam Clarey CreditAttribution: Adam Clarey commentedThe latest patch doesn't work for postgresql
Comment #37
Adam Clarey CreditAttribution: Adam Clarey commentedJust testing locally this works:
It needs to specify the string to use as glue, ie ','
Comment #38
smustgrave CreditAttribution: smustgrave at Mobomo commentedMoving back to needs work based on comment #36 and no test cases being added
Comment #40
Andrew Answer CreditAttribution: Andrew Answer as a volunteer commentedCan we have a list of entity links instead of list of strings? It would be very useful too.