VirtualMailManager/domain.py
branchv0.6.x
changeset 492 e5c2b3647971
parent 453 f2934105181b
child 510 1fa354bbdb90
--- a/VirtualMailManager/domain.py	Fri Apr 06 21:34:23 2012 +0000
+++ b/VirtualMailManager/domain.py	Sat Apr 07 00:45:57 2012 +0200
@@ -96,13 +96,17 @@
         are accounts, aliases and/or relocated users.
         """
         dbc = self._dbh.cursor()
-        dbc.execute('SELECT count(gid) FROM users WHERE gid = %(gid)u '
-                    'UNION SELECT count(gid) FROM alias WHERE gid = %(gid)u '
-                    'UNION SELECT count(gid) FROM relocated WHERE gid = '
-                    '%(gid)u' % {'gid': self._gid})
+        dbc.execute('SELECT '
+                    '(SELECT count(gid) FROM users WHERE gid = %(gid)u)'
+                    '  as account_count, '
+                    '(SELECT count(gid) FROM alias WHERE gid = %(gid)u)'
+                    '  as alias_count, '
+                    '(SELECT count(gid) FROM relocated WHERE gid = %(gid)u)'
+                    '  as relocated_count'
+                    % {'gid': self._gid})
         result = dbc.fetchall()
         dbc.close()
-        result = [count[0] for count in result]
+        result = result[0]
         if any(result):
             keys = ('account_count', 'alias_count', 'relocated_count')
             raise DomErr(_(u'There are %(account_count)u accounts, '