2013-04-30 56 views
0

我们有一个非常复杂的查询,我们使用eval()函数来评估一些数据。OrientDB:AND运算符在eval()函数内

但似乎AND运算符不正确处理eval()内。

例如:

if(eval('#20:34 IN out[@class='attempts'][email protected] AND \'b\' IN out[@class='attempts'].choice'), true, false) as attempt_b

在这个例子中,我们期待与#20:34,并与“B”的“选择”属性,是要回报的@rid只得到数据为真

“out”字段有$ current。@ rid我们的SELECT查询。

这是示例数据:

out ------ in ---- choices 
14:3 ---- 20:34 ------ b 
14:4 ---- 20:34 ------ a 
14:7 ---- 20:34 ------ c 
14:8 ---- 20:34 ------ d 

例:if(eval('#20:34 IN out[@class='attempts'][email protected] AND \'" + choice + "\' IN out[@class='attempts'].choice'), true, false) as attempt_choice

1)[email protected] = #14:3 and choice is 'a'

Return Output: true 
Expected output: false (since there is no #20:34 with a choice of "A" in [email protected] which is #14:3) 

2.)[email protected] = #14:3 and choice is 'b'

Return Output: true 
Expected output: true 

3)[email protected] = #14:3 and choice is 'c'

Return Output: true 
Expected output: false (since there is no #20:34 with a choice of "c" in [email protected] which is #14:3) 

4)[email protected] = #14:3 and choice is 'd'

Return Output: true 
Expected output: false (since there is no #20:34 with a choice of "d" in [email protected] which is #14:3)` 

我不知道这是否只是我们的查询问题或orientdb。如果有人能够引导我达到我们想要实现的目标,这将是一个很大的帮助。

回答

0

我认为这是一个引号问题:你关心的是'b'而不是其他的。试试像这样:

if(eval("#20:34 IN out[@class='attempts'][email protected] AND 'b' IN out[@class='attempts'].choice"), true, false) as attempt_b