[daisy] Evaluation of a boolean field in a query restriction part returns an error (Daisy 1.5.1)

Olivier Lange wire at petit-atelier.ch
Thu Mar 15 09:42:47 CDT 2007


Bruno Dumon wrote:
> On Wed, 2007-03-14 at 18:07 +0100, Olivier Lange wrote:
>> Hello,
>>
>> I am using Daisy 1.5.1 and I just noticed that the following query:
>>
>>   SELECT name WHERE( documentType = 'Even')
>>   AND( $EvenEnfants = true)
>>
>> where $EvenEnfants is a field of type Boolean (single value, no selection list, no ACL allowed), returns an error:
>>
>>   Received exception from repository server.
>>   Error performing query.
>>   Error parsing expression.
>>   Expected a value expression at the right-hand side of comparison operator "=" at line 2, column 19
>>
>> The boolean field 'EvenEnfants' is required within the 'Even' document type.
>>
>> I tried to rewrite the query, for instance:
>>
>>   SELECT name WHERE( documentType = 'Even')
>>   AND( $EvenEnfants = 1)
>>
>> but got an error in any case; for the above: 
>>
>>   Received exception from repository server.
>>   Error performing query.
>>   Invalid boolean value: "1" (should be 'true' or 'false').
>>
>> Is this a bug, a known issue? Is there a workaround? I've been searching in the mailing list archives and JIRA without luck.
> 
> Hi,
> 
> The correct syntax is:
> 
> $EvenEnfants = 'true'
> 
> thus the single quotes should be included.
> 
> The reason for this is implementation history: there's currently a
> difference between 'value expressions' (which can be compared using
> things like =, <, ... and given as arguments to functions) and
> 'predicate expressions' which are true or false and can only be and-ed
> or or-ed. The token "true" happens to be a predicate expression (it was
> introduced to be able to search for all documents: "where true"). This
> will probably be refactored in the future.
> 
> I've adjusted the exception message to tell the quotes should be
> included.

Many thanks Bruno for the clarification. I thought "true" and "false" were boolean literals.

This query works perfectly:

  SELECT ... WHERE( ...) AND( $EvenEnfants = 'true')

At first, I also thought of:

  ... $EvenEnfants = (1=1)

that also produced an error:

  [...]
  Error parsing expression.
  Expected a value expression at the right-hand side of comparison operator "="

which I didn't understand well. I noticed that the expression "WHERE (1=1)" worked well.

Now I understand:

 * the expression "(1=1)", as well as the token "true" result in a _predicate expression_ and not a _value expression_, so it can only be AND-ed and OR-ed;

 * "'true'" is a string and within the expression "$EvenEnfants = 'true'", $EvenEnfants gets implicitely casted to a string; both are value expression and thus can be compared using the operators =.

I also thought of using a function:

  $EvenEnfants = true()

(this expression does not work.)

Kind regards,

--
Olivier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3605 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.cocoondev.org/pipermail/daisy/attachments/20070315/6db9f230/smime-0001.bin


More information about the daisy mailing list