【问题标题】:OrientDB: AND operator inside eval() functionOrientDB:eval() 函数中的 AND 运算符
【发布时间】:2013-04-30 12:57:33
【问题描述】:

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

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

例如:

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

在该示例中,我们希望仅获取 @rid 为 #20:34 且“选择”属性为“b”的数据,该属性将返回 true

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

这是示例数据:

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的问题。如果有人能带领我实现我们想要实现的目标,那将是一个很大的帮助。

【问题讨论】:

    标签: sql eval orientdb and-operator


    【解决方案1】:

    我认为这是引号的问题:您关心的是转义 'b' 而不是其余的。尝试类似:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      • 2015-10-10
      • 2020-10-24
      • 1970-01-01
      • 1970-01-01
      • 2014-04-22
      相关资源
      最近更新 更多