[Cubicweb] An rql bug ?

Alain Leufroy alain.leufroy at logilab.fr
Thu Feb 12 14:10:06 CET 2015

Sylvain Thénault <sylvain.thenault at logilab.fr> writes:

>> I had troubles explaining constraints with that issue when the subject
>> of a relation has more than one entity type. For example:
>> class run(RelationDefinition):
>>     subject = ('Project', 'System')
>>     object = 'Subprocess'
>>     ...
>> class in_project(RelationDefinition):
>>     subject = 'Subject'
>>     object = 'System'
>> class can_run(RelationDefinition):
>>     subject = 'CWUser'
>>     object = 'Project'
>> And I would like to write the following permission rule on `run`:
>> RRQLExpression('EXISTS(U can_run O) OR EXISTS(U can_run X, O in_project X)')
>> Adding this permission rule fails with a "type inconsistancy"
>> exception from rql.
>> Looking into the rql code, it seems that the type checker consideres the
>> OR like an AND, that is the types in the first part 'and' the types of
>> variables in the second part must be similar.
> That's because of the way the type resolver work. It uses Constraint Programming
> for computing possible types for variables, and every relation 'X rel Y' add
> some constraints to the CSP, depending on the schema, without considering OR nor
> In your case, you should use 2 separated expression, those leading to type
> resolver error should be discarded at run time.

All RRQLExpressions given to a constraint rule are 'joined' with
'EXISTS(...) OR EXISTS(...).
It seems that hooks is the only way to check that kind of constraint.

More information about the Cubicweb mailing list