--- a/server/rqlannotation.py Wed Jan 07 09:47:56 2009 +0100
+++ b/server/rqlannotation.py Wed Jan 07 14:55:16 2009 +0100
@@ -36,15 +36,14 @@
if not var.stinfo['selected'] and len(var.stinfo['possibletypes']) > 1:
need_intersect = True
break
- else:
- if rschema.inlined:
- try:
- var = rel.children[1].children[0].variable
- except AttributeError:
- pass # rewritten variable
- else:
- if not var.stinfo['constnode']:
- need_distinct = True
+ if rschema.inlined:
+ try:
+ var = rel.children[1].children[0].variable
+ except AttributeError:
+ pass # rewritten variable
+ else:
+ if not var.stinfo['constnode']:
+ need_distinct = True
elif getrschema(rel.r_type).symetric:
for vref in rel.iget_nodes(VariableRef):
stinfo = vref.variable.stinfo
--- a/server/sources/rql2sql.py Wed Jan 07 09:47:56 2009 +0100
+++ b/server/sources/rql2sql.py Wed Jan 07 14:55:16 2009 +0100
@@ -488,7 +488,10 @@
sql.insert(1, 'FROM (SELECT 1) AS _T')
sqls.append('\n'.join(sql))
if select.need_intersect:
- return '\nINTERSECT\n'.join(sqls)
+ if distinct:
+ return '\nINTERSECT\n'.join(sqls)
+ else:
+ return '\nINTERSECT ALL\n'.join(sqls)
elif distinct:
return '\nUNION\n'.join(sqls)
else:
--- a/server/test/unittest_rql2sql.py Wed Jan 07 09:47:56 2009 +0100
+++ b/server/test/unittest_rql2sql.py Wed Jan 07 14:55:16 2009 +0100
@@ -746,11 +746,11 @@
WHERE P.for_user IS NULL'''),
('Any S WHERE NOT X in_state S, X is IN(Affaire, EUser)',
- '''SELECT S.eid
+ '''SELECT DISTINCT S.eid
FROM Affaire AS X, State AS S
WHERE (X.in_state IS NULL OR X.in_state!=S.eid)
INTERSECT
-SELECT S.eid
+SELECT DISTINCT S.eid
FROM EUser AS X, State AS S
WHERE (X.in_state IS NULL OR X.in_state!=S.eid)'''),
]