server/sources/rql2sql.py
changeset 4845 dc351b96f596
parent 4831 c5aec27c1bf7
parent 4836 3e3c4917e94e
child 5004 4cc020ee70e2
child 5010 b2c5aee8ca3f
--- a/server/sources/rql2sql.py	Tue Mar 09 11:01:44 2010 +0100
+++ b/server/sources/rql2sql.py	Tue Mar 09 11:05:29 2010 +0100
@@ -341,6 +341,9 @@
                             }
         if not self.dbms_helper.union_parentheses_support:
             self.union_sql = self.noparen_union_sql
+        if self.dbms_helper.fti_need_distinct:
+            self.__union_sql = self.union_sql
+            self.union_sql = self.has_text_need_distinct_union_sql
         self._lock = threading.Lock()
         if attrmap is None:
             attrmap = {}
@@ -374,6 +377,12 @@
         finally:
             self._lock.release()
 
+    def has_text_need_distinct_union_sql(self, union, needalias=False):
+        if getattr(union, 'has_text_query', False):
+            for select in union.children:
+                select.need_distinct = True
+        return self.__union_sql(union, needalias)
+
     def union_sql(self, union, needalias=False): # pylint: disable-msg=E0202
         if len(union.children) == 1:
             return self.select_sql(union.children[0], needalias)