I'm trying to use the OGM from pyorient to match records which have nulls in some of their fields.
I managed to get most things working by looking through the unit tests on GitHub but I couldn't find any examples there or in the docs. I also couldn't see any issues on GitHub, so I guess I'm just approaching it the wrong way.
pyOrient version : 1.5.5
python version : 3.6.3
OrientDB version : 2.2.31
I've put an end to end set up below to highlight the problem, which is with the final query.
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]
Many thanks,
Graham
Seems to be a defect, as per my comment. Have raised an issue on GitHub.
Issue #262: OGM: NULL fields not queried correctly