From f9023da5e2d5c23ba1d3560feaf3b88136d8877f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 24 Jun 2007 09:19:48 +0000 Subject: [PATCH] "fix for bug #928: Distribution lists are not working with pgsql, thanks to Peter Eisentraut postgres requires that expressions in order by appear in the columns of a distinct select" --- addressbook/inc/class.socontacts_sql.inc.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addressbook/inc/class.socontacts_sql.inc.php b/addressbook/inc/class.socontacts_sql.inc.php index 7f3a5b2cbf..a2f0c828a1 100644 --- a/addressbook/inc/class.socontacts_sql.inc.php +++ b/addressbook/inc/class.socontacts_sql.inc.php @@ -328,6 +328,12 @@ class socontacts_sql extends so_sql $filter[] = $this->table_name.'.contact_owner='.(int)$filter['owner']; unset($filter['owner']); } + // postgres requires that expressions in order by appear in the columns of a distinct select + if ($this->db->Type != 'mysql' && preg_match("/(\w+<>'')/",$order_by,$matches)) + { + if (!is_array($extra_cols)) $extra_cols = $extra_cols ? explode(',',$extra_cols) : array(); + $extra_cols[] = $matches[1]; + } } $rows =& parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);