Commit 004d0c1c authored by mkanat%kerio.com's avatar mkanat%kerio.com

Bug 286686: ORDER BY column needs to be selected or grouped

Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=mkanat, a=justdave
parent 95973482
...@@ -598,7 +598,8 @@ sub match { ...@@ -598,7 +598,8 @@ sub match {
# Build the query. # Build the query.
my $sqlstr = &::SqlQuote($wildstr); my $sqlstr = &::SqlQuote($wildstr);
my $query = "SELECT DISTINCT userid, realname, login_name " . my $query = "SELECT DISTINCT userid, realname, login_name, " .
"LENGTH(login_name) AS namelength " .
"FROM profiles "; "FROM profiles ";
if (&::Param('usevisibilitygroups')) { if (&::Param('usevisibilitygroups')) {
$query .= ", user_group_map "; $query .= ", user_group_map ";
...@@ -613,7 +614,7 @@ sub match { ...@@ -613,7 +614,7 @@ sub match {
"AND grant_type <> " . GRANT_DERIVED; "AND grant_type <> " . GRANT_DERIVED;
} }
$query .= " AND disabledtext = '' " if $exclude_disabled; $query .= " AND disabledtext = '' " if $exclude_disabled;
$query .= "ORDER BY length(login_name) "; $query .= "ORDER BY namelength ";
$query .= $dbh->sql_limit($limit) if $limit; $query .= $dbh->sql_limit($limit) if $limit;
# Execute the query, retrieve the results, and make them into # Execute the query, retrieve the results, and make them into
...@@ -648,7 +649,8 @@ sub match { ...@@ -648,7 +649,8 @@ sub match {
my $sqlstr = &::SqlQuote(uc($str)); my $sqlstr = &::SqlQuote(uc($str));
my $query = "SELECT DISTINCT userid, realname, login_name " . my $query = "SELECT DISTINCT userid, realname, login_name, " .
"LENGTH(login_name) AS namelength " .
"FROM profiles"; "FROM profiles";
if (&::Param('usevisibilitygroups')) { if (&::Param('usevisibilitygroups')) {
$query .= ", user_group_map"; $query .= ", user_group_map";
...@@ -665,7 +667,7 @@ sub match { ...@@ -665,7 +667,7 @@ sub match {
" AND grant_type <> " . GRANT_DERIVED; " AND grant_type <> " . GRANT_DERIVED;
} }
$query .= " AND disabledtext = ''" if $exclude_disabled; $query .= " AND disabledtext = ''" if $exclude_disabled;
$query .= " ORDER BY length(login_name)"; $query .= " ORDER BY namelength";
$query .= " " . $dbh->sql_limit($limit) if $limit; $query .= " " . $dbh->sql_limit($limit) if $limit;
&::PushGlobalSQLState(); &::PushGlobalSQLState();
&::SendSQL($query); &::SendSQL($query);
......
...@@ -322,7 +322,8 @@ sub get_inactive_bugs { ...@@ -322,7 +322,8 @@ sub get_inactive_bugs {
WHERE longdescs.bug_id IN ($buglist) WHERE longdescs.bug_id IN ($buglist)
$date_bits } . $date_bits } .
$dbh->sql_group_by('longdescs.bug_id', $dbh->sql_group_by('longdescs.bug_id',
'bugs.short_desc, bugs.bug_status') . qq{ 'bugs.short_desc, bugs.bug_status,
longdescs.bug_when') . qq{
ORDER BY longdescs.bug_when}; ORDER BY longdescs.bug_when};
$sth = $dbh->prepare($q); $sth = $dbh->prepare($q);
$sth->execute(@{$date_values}); $sth->execute(@{$date_values});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment