NOT operator not equivalent to NOT EXISTS
According to the documentation:
NOT X relation Y is equivalent to NOT EXISTS(X relation Y)
But while testing the requests Any X WHERE X is City, NOT (X eid 840)
and Any X WHERE X is City, NOT EXISTS(X eid 840)
on the tuto cube, I find different results. The first request gives the right result, but the second gives the opposite (only eid 840).
Here is the debug output for each request:
>>> rql('Any X WHERE X is City, NOT (X eid 840)')
********************************************************************************
querier input Any X WHERE X is City, NOT (X eid 840) None
/home/avergnet/dev/tuto/venv/lib/python3.7/site-packages/rql/stcheck.py:481: TargetRenamedDeprecationWarning: [logilab.common.deprecation] rschema has been renamed and is deprecated, uses relation_schema_for instead
rschema = self.schema.rschema(rtype)
/home/avergnet/dev/tuto/venv/lib/python3.7/site-packages/rql/stcheck.py:433: TargetRenamedDeprecationWarning: [logilab.common.deprecation] rschema has been renamed and is deprecated, uses relation_schema_for instead
rschema = self.schema.rschema(child.r_type)
/home/avergnet/dev/tuto/venv/lib/python3.7/site-packages/rql/stcheck.py:810: TargetRenamedDeprecationWarning: [logilab.common.deprecation] rschema has been renamed and is deprecated, uses relation_schema_for instead
rschema = self.schema.rschema(rtype)
rql for system source: Any X WHERE X is City, NOT X eid 840
args {}
cache key ('Any X WHERE X is City, NOT X eid 840',)
solutions [{'X': 'City'}]
exec SELECT _X.cw_eid
FROM cw_City AS _X
WHERE NOT (_X.cw_eid=840) {} <connection object at 0x7f2f114b4440; dsn: 'dbname=tuto-instance2 user=avergnet', closed: 0>
--> [[842], [844], [846], [848], [850], [852], [854], [856], [858], [860]] ... 914 time: 0.002296924591064453
<resultset 'Any X WHERE X is City, NOT (X eid 840)' (914 rows):
[842] (('City',))
[844] (('City',))
[846] (('City',))
[848] (('City',))
[850] (('City',))
[852] (('City',))
[854] (('City',))
[856] (('City',))
[858] (('City',))
[860] (('City',))
... (('City',))>
>>> rql('Any X WHERE X is City, NOT EXISTS(X eid 840)')
********************************************************************************
querier input Any X WHERE X is City, NOT EXISTS(X eid 840) None
/home/avergnet/dev/tuto/venv/lib/python3.7/site-packages/rql/stcheck.py:810: TargetRenamedDeprecationWarning: [logilab.common.deprecation] rschema has been renamed and is deprecated, uses relation_schema_for instead
rschema = self.schema.rschema(rtype)
rql for system source: Any 840
args {}
cache key ('Any 840',)
solutions [{}]
exec SELECT 840 {} <connection object at 0x7f2f114b4440; dsn: 'dbname=tuto-instance2 user=avergnet', closed: 0>
--> [[840]] time: 0.0004520416259765625
<resultset 'Any X WHERE X is City, NOT EXISTS(X eid 840)' (1 rows): [840] (('City',))>