0

我在 OrientDB Studio 中发现了 SQL 查询的奇怪行为(它也在 REST 协议中重复)。

我的服务器版本是 2.2.5

我班的数据:

select * from name

结果:

{
    "result": [
        {
            "@type": "d",
            "@rid": "#25:0",
            "@version": 1,
            "@class": "name",
            "surname": "foo surname",
            "name": "foo name"
        },
        {
            "@type": "d",
            "@rid": "#26:0",
            "@version": 1,
            "@class": "name",
            "surname": "bar surname",
            "name": "bar name"
        },
        {
            "@type": "d",
            "@rid": "#27:0",
            "@version": 1,
            "@class": "name",
            "surname": "O'brien",
            "name": "baz"
        }
    ],
    "notification": "Query executed in 0.069 sec. Returned 3 record(s)"
 }

其中 surname 和 name 属性是文本字段。

我在 Studio 中创建了一些 SQL 查询:

select * from name WHERE surname='O\'brien'

结果:

{
"result": [
    {
        "@type": "d",
        "@rid": "#27:0",
        "@version": 1,
        "@class": "name",
        "surname": "O'brien",
        "name": "baz"
       }
   ],
"notification": "Query executed in 0.016 sec. Returned 1 record(s)"

}

效果很好。

下一个:

select * from name WHERE NOT (surname='O\'brien')

结果:

{
"result": [
    {
        "@type": "d",
        "@rid": "#25:0",
        "@version": 1,
        "@class": "name",
        "surname": "foo surname",
        "name": "foo name"
    },
    {
        "@type": "d",
        "@rid": "#26:0",
        "@version": 1,
        "@class": "name",
        "surname": "bar surname",
        "name": "bar name"
    },
    {
        "@type": "d",
        "@rid": "#27:0",
        "@version": 1,
        "@class": "name",
        "surname": "O'brien",
        "name": "baz"
    }
],
"notification": "Query executed in 0.015 sec. Returned 3 record(s)"

}

在这种情况下,我得到了意想不到的第三个结果。

下一个:

select * from name WHERE (NOT (surname='bar surname'))

结果:

{
   "result": [
       {
           "@type": "d",
           "@rid": "#25:0",
           "@version": 1,
           "@class": "name",
           "surname": "foo surname",
           "name": "foo name"
        },
        {
           "@type": "d",
           "@rid": "#27:0",
           "@version": 1,
           "@class": "name",
           "surname": "O'brien",
           "name": "baz"
        }
    ],
    "notification": "Query executed in 0.017 sec. Returned 2 record(s)"
}

看起来不错。

下一个:

select * from name WHERE (NOT (surname='O\'brien'))

结果:

java.lang.NullPointerException

下一个:

select * from name WHERE (surname='O\'brien')

结果:

Empty result

我的问题 - 这是错误,还是我做错了什么?

这些查询是查询构建器的一部分,所以我需要了解 OrientDB 括号中的工作原理。

谢谢。

4

1 回答 1

0

ODB ver2.2.12

使用不同类型的报价。

我的数据:

select from V

{
    "result": [
        {
            "@type": "d",
            "@rid": "#9:0",
            "@version": 1,
            "@class": "V",
            "name": "O'Brian"
        },
        {
            "@type": "d",
            "@rid": "#10:0",
            "@version": 1,
            "@class": "V",
            "name": "Pippo"
        }
    ],
    "notification": "Query executed in 0.013 sec. Returned 2 record(s)"
}

select from V where NOT (name = "O'Brian")

{
    "result": [
        {
            "@type": "d",
            "@rid": "#10:0",
            "@version": 1,
            "@class": "V",
            "name": "Pippo"
        }
    ],
    "notification": "Query executed in 0.023 sec. Returned 1 record(s)"
}
于 2016-10-24T15:15:04.973 回答