#161 domain list incorrect SELECT

v_2.3
closed-fixed
nobody
Database (41)
5
2011-04-10
2009-09-15
ksb
No

Hi!
2.3rc7
For me list-domain.php gives an error:
DEBUG INFORMATION:
Invalid query: ERROR: column "domain.uid" must appear in the GROUP BY clause or be used in an aggregate function
So as I have uid and gid columns (used by dovecot) in domain and mailboxes tables (now filled with default values) error comes out. Backend - ppostgresql.
# fetch domain data and number of mailboxes
# (PgSQL requires the extensive GROUP BY statement, https://sourceforge.net/forum/message.php?msg_id=7386240\)
$query = "
SELECT domain.* , COUNT( DISTINCT mailbox.username ) AS mailbox_count
FROM domain
LEFT JOIN mailbox ON domain.domain = mailbox.domain
$where
GROUP BY domain.domain, domain.description, domain.aliases, domain.mailboxes,
domain.maxquota, domain.quota, domain.transport, domain.backupmx, domain.created,
domain.modified, domain.active
ORDER BY domain.domain
";
$result = db_query($query);

Good comment, yeah ;) but no so good practice to use "SELECT * " even it isn't postgresql and without GROUP BY clause.
I think, best way to resove this problem would be exact select of columns!

Discussion

  • ksb

    ksb - 2010-02-04

    Bug still exists in 2.3 final!
    Resolution is easy as 123, exact select on columns.

     
  • Christian Boltz

    Christian Boltz - 2011-04-10
    • status: open --> closed-fixed
     
  • Christian Boltz

    Christian Boltz - 2011-04-10

    Even if the solution is easy, it needs some time to do it - and sometimes even 10 minutes can be hard to find...

    Finally fixed in SVN r1028 (trunk) and r1029 (2.3 branch).

    Thanks for your bugreport!

     

Log in to post a comment.