OrientDB:AND运算符在eval()函数内

时间:2013-04-30 12:57:34

标签: sql eval orientdb and-operator

我们有一个非常复杂的查询,我们使用eval()函数来评估一些数据。

但似乎在eval()中没有正确处理AND运算符。

例如:

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

在该示例中,我们期望仅获得具有#20:34的@rid并且具有“b”的“choice”属性的数据,该属性将返回到真

“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'].in.@rid AND \'" + choice + "\' IN out[@class='attempts'].choice'), true, false) as attempt_choice

1。)$current.@rid = #14:3 and choice is 'a'

Return Output: true
Expected output: false (since there is no #20:34 with a choice of "A" in current.@rid which is #14:3)

2。)$current.@rid = #14:3 and choice is 'b'

Return Output: true
Expected output: true

3。)$current.@rid = #14:3 and choice is 'c'

Return Output: true
Expected output: false (since there is no #20:34 with a choice of "c" in current.@rid which is #14:3)

4。)$current.@rid = #14:3 and choice is 'd'

 Return Output: true
 Expected output: false (since there is no #20:34 with a choice of "d" in current.@rid which is #14:3)`

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

1 个答案:

答案 0 :(得分:0)

我认为这是一个引用问题:你关心逃避'b'而不是其他人。尝试类似:

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