In addition of the classic leafs, you can add operators.
« Wait... what do you name leafs? »
A leaf, is a tuple of 3 elements composed of:
- a field name
- an operator (as string)
- a value
('active', '=', True)
('foo', '!=', 'bar')
('id', 'in', [7, 13, 42, 666])
('id', '=', False)
('name', 'like', 'tiny')
« And which operators are allowed? »
Like the last week notation, the AND ('&') and OR ('|') operators are allowed . Unlike the last week notation, the arity of these operators is fixed to 2.
And yes, the one you have all been waiting for is now in: The NOT ('!') operator. This one has an arity of 1.
For compatibility with existing domains, the AND operator is applied by default.
« So, what looks like this new new notation? »
Some examples:
['&', ('active', '=', True), ('value', '!=', 'foo')]
['|', ('active', '=', True), ('state', 'in', ['open', 'draft'])
['&', ('active', '=', True), '|', '!', ('state', '=', 'closed'), ('state', '=', 'draft')]
['|', '|', ('state', '=', 'open'), ('state', '=', 'closed'), ('state', '=', 'draft')]
['!', '&', '!', ('id', 'in', [42, 666]), ('active', '=', False)]
PS: Tanks to Najlâa and Olivier for the review.

1 comments:
really great work, i am reading your code in expression.py and i want to know if is posible support BETWEEN command there, so i am debbuging that, but if you can help me with any info, thanks
regards,
Post a Comment