Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
333b8fcb
You need to sign in or sign up before continuing.
Commit
333b8fcb
authored
Jul 06, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 552919: Sort group_concat results so that they sort correctly for buglists
r=mkanat, a=mkanat (module owner)
parent
569c6b69
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
16 deletions
+37
-16
Mysql.pm
Bugzilla/DB/Mysql.pm
+8
-5
Oracle.pm
Bugzilla/DB/Oracle.pm
+1
-1
Pg.pm
Bugzilla/DB/Pg.pm
+22
-3
DB.pm
Bugzilla/Install/DB.pm
+2
-2
Search.pm
Bugzilla/Search.pm
+4
-5
No files found.
Bugzilla/DB/Mysql.pm
View file @
333b8fcb
...
...
@@ -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
{
...
...
Bugzilla/DB/Oracle.pm
View file @
333b8fcb
...
...
@@ -119,7 +119,7 @@ sub bz_explain {
sub
sql_group_concat
{
my
(
$self
,
$text
,
$separator
)
=
@_
;
$separator
||=
"','"
;
$separator
=
$self
->
quote
(
', '
)
if
!
defined
$separator
;
return
"group_concat(T_CLOB_DELIM($text, $separator))"
;
}
...
...
Bugzilla/DB/Pg.pm
View file @
333b8fcb
...
...
@@ -98,9 +98,14 @@ sub bz_last_key {
}
sub
sql_group_concat
{
my
(
$self
,
$text
,
$separator
)
=
@_
;
$separator
||=
"','"
;
return
"array_to_string(array_accum($text), $separator)"
;
my
(
$self
,
$text
,
$separator
,
$sort
)
=
@_
;
$sort
=
1
if
!
defined
$sort
;
$separator
=
$self
->
quote
(
', '
)
if
!
defined
$separator
;
my
$sql
=
"array_accum($text)"
;
if
(
$sort
)
{
$sql
=
"array_sort($sql)"
;
}
return
"array_to_string($sql, $separator)"
;
}
sub
sql_istring
{
...
...
@@ -224,6 +229,20 @@ sub bz_setup_database {
)"
);
}
$self
->
do
(
<<
'END'
);
CREATE
OR
REPLACE
FUNCTION
array_sort
(
ANYARRAY
)
RETURNS
ANYARRAY
LANGUAGE
SQL
IMMUTABLE
STRICT
AS
$$
SELECT
ARRAY
(
SELECT
$1
[
s
.
i
]
AS
each_item
FROM
generate_series
(
array_lower
(
$1
,
1
),
array_upper
(
$1
,
1
))
AS
s(i)
ORDER BY each_item
);
$$
;
END
# PostgreSQL doesn't like having *any* index on the thetext
# field, because it can't have index data longer than 2770
# characters on that field.
...
...
Bugzilla/Install/DB.pm
View file @
333b8fcb
...
...
@@ -3198,8 +3198,8 @@ sub _populate_bugs_fulltext {
q{INSERT INTO bugs_fulltext (bug_id, short_desc, comments,
comments_noprivate)
SELECT bugs.bug_id, bugs.short_desc, }
.
$dbh
->
sql_group_concat
(
'longdescs.thetext'
,
$newline
)
.
', '
.
$dbh
->
sql_group_concat
(
'nopriv.thetext'
,
$newline
)
.
.
$dbh
->
sql_group_concat
(
'longdescs.thetext'
,
$newline
,
0
)
.
', '
.
$dbh
->
sql_group_concat
(
'nopriv.thetext'
,
$newline
,
0
)
.
qq{ FROM bugs
LEFT JOIN longdescs
ON bugs.bug_id = longdescs.bug_id
...
...
Bugzilla/Search.pm
View file @
333b8fcb
...
...
@@ -308,10 +308,10 @@ sub COLUMNS {
.
" * ($actual_time / ($actual_time + bugs.remaining_time))"
.
" END)"
,
'flagtypes.name'
=>
$dbh
->
sql_group_concat
(
'DISTINCT '
.
$dbh
->
sql_string_concat
(
'flagtypes.name'
,
'flags.status'
),
"', '"
),
'flagtypes.name'
=>
$dbh
->
sql_group_concat
(
'DISTINCT '
.
$dbh
->
sql_string_concat
(
'flagtypes.name'
,
'flags.status'
)
),
'keywords'
=>
$dbh
->
sql_group_concat
(
'DISTINCT keyworddefs.name'
,
"', '"
),
'keywords'
=>
$dbh
->
sql_group_concat
(
'DISTINCT keyworddefs.name'
),
);
# Backward-compatibility for old field names. Goes new_name => old_name.
...
...
@@ -354,8 +354,7 @@ sub COLUMNS {
}
elsif
(
$field
->
type
==
FIELD_TYPE_MULTI_SELECT
)
{
$sql
=
$dbh
->
sql_group_concat
(
'DISTINCT map_bug_'
.
$field
->
name
.
'.value'
,
$dbh
->
quote
(
', '
));
'DISTINCT map_bug_'
.
$field
->
name
.
'.value'
);
}
else
{
$sql
=
'bugs.'
.
$field
->
name
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment