--- a/server/sources/rql2sql.py Mon Jul 05 17:56:02 2010 +0200
+++ b/server/sources/rql2sql.py Tue Jul 06 09:42:13 2010 +0200
@@ -818,7 +818,7 @@
assert lhsvar is not None
if isinstance(relation.parent, Not) \
and len(lhsvar.stinfo['relations']) > 1 \
- and (rhsvar is None or rhsvar._q_invariant):
+ and (rhsvar is not None and rhsvar._q_invariant):
self._state.done.add(relation.parent)
return '%s IS NULL' % self._inlined_var_sql(lhsvar, relation.r_type)
lhssql = self._inlined_var_sql(lhsvar, relation.r_type)
--- a/server/test/unittest_rql2sql.py Mon Jul 05 17:56:02 2010 +0200
+++ b/server/test/unittest_rql2sql.py Tue Jul 06 09:42:13 2010 +0200
@@ -1031,9 +1031,16 @@
('Any X WHERE NOT Y for_user X, X eid 123',
'''SELECT 123
-WHERE NOT (EXISTS(SELECT 1 FROM cw_CWProperty AS _Y WHERE _Y.cw_for_user=123))
-'''),
+WHERE NOT (EXISTS(SELECT 1 FROM cw_CWProperty AS _Y WHERE _Y.cw_for_user=123))'''),
+ ('DISTINCT Any X WHERE X from_entity OET, NOT X from_entity NET, OET name "Image", NET eid 1',
+ '''SELECT DISTINCT _X.cw_eid
+FROM cw_CWAttribute AS _X, cw_CWEType AS _OET
+WHERE _X.cw_from_entity=_OET.cw_eid AND NOT (_X.cw_from_entity=1) AND _OET.cw_name=Image
+UNION
+SELECT DISTINCT _X.cw_eid
+FROM cw_CWEType AS _OET, cw_CWRelation AS _X
+WHERE _X.cw_from_entity=_OET.cw_eid AND NOT (_X.cw_from_entity=1) AND _OET.cw_name=Image'''),
]
INTERSECT = [