【问题标题】:querying null fields using pyorient OGM使用 pyorient OGM 查询空字段
【发布时间】:2018-06-22 03:57:21
【问题描述】:

我正在尝试使用 pyorient 中的 OGM 来匹配某些字段中包含空值的记录。

通过查看 GitHub 上的单元测试,我设法让大多数事情正常工作,但我在那儿或文档中找不到任何示例。我在 GitHub 上也看不到任何问题,所以我想我只是以错误的方式接近它。

pyOrient 版本:1.5.5

python 版本:3.6.3

OrientDB 版本:2.2.31

我在下面设置了端到端设置以突出问题,即最终查询。

from pyorient.ogm import Graph, Config, declarative
from pyorient.ogm.property import (String, Integer)
ogm_config = Config.from_url("localhost/ogm_test", "root", "root", initial_drop = True)
g = Graph(ogm_config)
Node = declarative.declarative_node()

class table_a(Node):
    element_plural = 'table_a'
    column_1 = String()
    column_2 = Integer()
g.create_all(Node.registry)

db_data = [
    {"column_1":"Test 1", "column_2" : 1},
    {"column_1":"Test 1"},
    {"column_1":"Test 2", "column_2" : 1},
    {"column_1":"Test 2", "column_2" : None},
    ]

for data in db_data:
    res = g.table_a.create(**data)

query_res = g.table_a.query(**db_data[0]).all()
print(len(query_res)) # expected 1 got 1 i.e. (db_data[0])

query_res = g.table_a.query(**db_data[1]).all()
print(len(query_res)) # expected 2 got 2 i.e. (db_data[0] and db_data[1])

query_res = g.table_a.query(**db_data[2]).all()
print(len(query_res)) # expected 1 got 1 i.e. (db_data[2])

query_res = g.table_a.query(**db_data[3]).all()
print(len(query_res)) # expected 1 got 0 ??????? I expected db_data[3]

非常感谢,

格雷厄姆

【问题讨论】:

  • 似乎是一个错误。 query.py:build_wheres() 返回'column_1 = "Test 2" and column_2=null',但我认为它应该返回'column_1 = "Test 2" and column_2 IS null'。将在 Github 中提出问题进行澄清。

标签: python null pyorient


【解决方案1】:

根据我的评论,这似乎是一个缺陷。已在 GitHub 上提出问题。

问题 #262:OGM:未正确查询 NULL 字段

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-13
    • 1970-01-01
    • 1970-01-01
    • 2018-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多