From 333b8fcbaad05e5e3ab01a897529560dea37dd53 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Tue, 6 Jul 2010 17:13:46 -0700 Subject: Bug 552919: Sort group_concat results so that they sort correctly for buglists r=mkanat, a=mkanat (module owner) --- Bugzilla/DB/Mysql.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Bugzilla/DB/Mysql.pm') diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm index 4b90a2a34..7f3eb2ef8 100644 --- a/Bugzilla/DB/Mysql.pm +++ b/Bugzilla/DB/Mysql.pm @@ -126,12 +126,15 @@ sub bz_last_key { } sub sql_group_concat { - my ($self, $column, $separator) = @_; - my $sep_sql; - if ($separator) { - $sep_sql = " SEPARATOR $separator"; + my ($self, $column, $separator, $sort) = @_; + $separator = $self->quote(', ') if !defined $separator; + $sort = 1 if !defined $sort; + if ($sort) { + my $sort_order = $column; + $sort_order =~ s/^DISTINCT\s+//i; + $column = "$column ORDER BY $sort_order"; } - return "GROUP_CONCAT($column$sep_sql)"; + return "GROUP_CONCAT($column SEPARATOR $separator)"; } sub sql_regexp { -- cgit v1.2.1