server/sources/rql2sql.py
changeset 339 c0a0ce6c0428
parent 0 b97547f5f1fa
child 340 bfe0e95571aa
--- a/server/sources/rql2sql.py	Tue Jan 06 12:53:47 2009 -0800
+++ b/server/sources/rql2sql.py	Wed Jan 07 09:47:56 2009 +0100
@@ -76,7 +76,7 @@
         unstable.remove(varname)
         torewrite.add(var)
         newselect = Select()
-        newselect.need_distinct = False
+        newselect.need_distinct = newselect.need_intersect = False
         myunion = Union()
         myunion.append(newselect)
         # extract aliases / selection
@@ -487,7 +487,9 @@
             elif self._state.restrictions and self.dbms_helper.needs_from_clause:
                 sql.insert(1, 'FROM (SELECT 1) AS _T')
             sqls.append('\n'.join(sql))
-        if distinct:
+        if select.need_intersect:
+            return '\nINTERSECT\n'.join(sqls)
+        elif distinct:
             return '\nUNION\n'.join(sqls)
         else:
             return '\nUNION ALL\n'.join(sqls)