From 6860aeac1453c19b500a3f06b88657955b27789f Mon Sep 17 00:00:00 2001
From: Alexandre Boeglin <alex@nexedi.com>
Date: Thu, 26 Aug 2004 13:40:09 +0000
Subject: [PATCH] Autoselect table to append to column name in
 'order_by_expression', if column is only present in one table.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1438 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ZSQLCatalog/SQLCatalog.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py
index 6ce712817f..bd8e278eb9 100755
--- a/product/ZSQLCatalog/SQLCatalog.py
+++ b/product/ZSQLCatalog/SQLCatalog.py
@@ -657,7 +657,10 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
       try:
         new_sort_index = []
         for (k , v) in sort_index:
-          if query_table: k = query_table + '.' + k
+          if len(acceptable_key_map[key]) == 1 :
+            k = acceptable_key_map[key][0] + '.' + k
+          elif query_table:
+            k = query_table + '.' + k
           if v == 'descending' or v == 'reverse':
             from_table_dict[acceptable_key_map[k][0]] = 1 # We need this table to sort on it
             new_sort_index += ['%s DESC' % k]
-- 
2.30.9