ServicenotificationQuery: Fix grouping when *all* tables are being joined

refs #9009
This commit is contained in:
Johannes Meyer 2015-06-10 17:01:58 +02:00
parent 0ccb765954
commit 5ad93d138c

View File

@ -74,12 +74,12 @@ class ServicenotificationQuery extends IdoQuery
switch ($this->ds->getDbType()) { switch ($this->ds->getDbType()) {
case 'mysql': case 'mysql':
$concattedContacts = "GROUP_CONCAT(" $concattedContacts = "GROUP_CONCAT("
. "cno.name1 ORDER BY cno.name1 SEPARATOR ', '" . "DISTINCT cno.name1 ORDER BY cno.name1 SEPARATOR ', '"
. ") COLLATE latin1_general_ci"; . ") COLLATE latin1_general_ci";
break; break;
case 'pgsql': case 'pgsql':
// TODO: Find a way to order the contact alias list: // TODO: Find a way to order the contact alias list:
$concattedContacts = "ARRAY_TO_STRING(ARRAY_AGG(cno.name1), ', ')"; $concattedContacts = "ARRAY_TO_STRING(ARRAY_AGG(DISTINCT cno.name1), ', ')";
break; break;
case 'oracle': case 'oracle':
// TODO: This is only valid for Oracle >= 11g Release 2 // TODO: This is only valid for Oracle >= 11g Release 2
@ -178,6 +178,10 @@ class ServicenotificationQuery extends IdoQuery
'hgo.objecttype_id = ?', 'hgo.objecttype_id = ?',
3 3
); );
if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) {
$this->group(array('sn.notification_id', 'so.name2', 'so.name1'));
}
} }
/** /**
@ -219,7 +223,7 @@ class ServicenotificationQuery extends IdoQuery
4 4
); );
if (! $this->hasJoinedVirtualTable('contactnotifications')) { if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) {
$this->group(array('sn.notification_id', 'so.name2', 'so.name1')); $this->group(array('sn.notification_id', 'so.name2', 'so.name1'));
} }
} }
@ -234,9 +238,5 @@ class ServicenotificationQuery extends IdoQuery
's.service_object_id = so.object_id', 's.service_object_id = so.object_id',
array() array()
); );
if (! $this->hasJoinedVirtualTable('contactnotifications')) {
$this->group(array('sn.notification_id', 'so.name2', 'so.name1'));
}
} }
} }