6.0.0-beta1
7/12/25

[#10383] SQL error in duplicate search
Summary SQL error in duplicate search
Queue Turba
Queue Version 3.0.4
Type Bug
State Resolved
Priority 1. Low
Owners jan (at) horde (dot) org
Requester thpo+horde (at) dotrc (dot) de
Created 07/26/2011 (5100 days ago)
Due
Updated 08/08/2011 (5087 days ago)
Assigned
Resolved 08/08/2011 (5087 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
08/08/2011 04:35:05 PM Jan Schneider Assigned to Jan Schneider
State ⇒ Resolved
 
08/08/2011 04:34:58 PM Git Commit Comment #3 Reply to this comment
Changes have been made in Git for this ticket:

Some DBs require field names in ORDER BY to appear in SELECT list (Bug 
#10383).

  3 files changed, 5 insertions(+), 1 deletions(-)
http://git.horde.org/horde-git/-/commit/277daa7c3ccaaac2a1b6a1b770879bd9278a5975
08/03/2011 01:40:40 PM thpo+horde (at) dotrc (dot) de Comment #2 Reply to this comment
I had a quick look into it. The following patch resolves the problem 
(at least for me).

--- turba/lib/Driver/Sql.php    2011-08-03 15:39:05.242893493 +0200
+++ /tmp/10383.php      2011-08-03 15:38:56.482904733 +0200
@@ -257,7 +257,7 @@
              $nameFormat = 'first_last';
          }

-        $order = $this->_buildFields($fields);
+        //$order = $this->_buildFields($fields);
          $joins = $this->_buildJoin($fields);
          $where = $this->_buildWhere($fields);

@@ -274,7 +274,8 @@
                               $this->map['__owner'],
                               $this->map['__owner'],
                               $where[$i],
-                             $order[$i]);
+                             $this->map['__key']);
+                             //$order[$i]);

              /* Run query. */
              try {

07/26/2011 07:51:03 AM thpo+horde (at) dotrc (dot) de Comment #1
Priority ⇒ 1. Low
Patch ⇒ No
Milestone ⇒
Queue ⇒ Turba
Summary ⇒ SQL error in duplicate search
Type ⇒ Bug
State ⇒ Unconfirmed
Reply to this comment
/turba/search.php?search_mode=duplicate

2011-07-26T09:47:25+02:00 ERR: HORDE [turba] SQL QUERY FAILED: 
SQLSTATE[42P10]: Invalid column reference: 7 ERROR:  for SELECT 
DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ...IS NOT NULL AND a1.object_lastname <> '' ORDER BY a1.object_...
                                                              ^
         SELECT DISTINCT a1.object_id FROM turba_objects a1 JOIN turba_objects
           a2 ON a1.object_lastname = a2.object_lastname AND 
a1.object_firstname
           = a2.object_firstname AND a1.object_id <> a2.object_id WHERE
           a1.owner_id = 'thpo' AND a2.owner_id = 'thpo' AND a1.object_lastname
           IS NOT NULL AND a1.object_lastname <> '' ORDER BY
           a1.object_lastname,a1.object_firstname [pid 9137 on line 
808 of "/usr/share/php/Horde/Db/Adapter/Base.php"]

Saved Queries