Properties of StructuredRel relationships that are marked with a db_property property name override are properly written to the database but skipped during inflation, and thus are always filled with None when returned from queries.
Actual Behavior
Properties of StructuredRel relationships that are marked with a db_property property name override should be filled from their value in the database during inflation.
How to Reproduce the Problem
Create a StructuredRel with a property that uses db_property and attempt to round-trip the relationship to the database.
Simple Example
Simple reproduction using slightly modified versions of objects from the example code:
import neomodel
from neomodel import StringProperty, StructuredRel, StructuredNode, RelationshipTo, IntegerProperty
class FriendRel(StructuredRel):
property_one = IntegerProperty()
propertyTwo = IntegerProperty()
# This is a pattern I expect to be common in my workflow because python member variables are snake_case by
# convention but neo4j properties are camelCase by convention
# (https://neo4j.com/docs/getting-started/appendix/graphdb-concepts/#graphdb-naming-conventions)
property_three = IntegerProperty(db_property="propertyThree")
class Person(StructuredNode):
name = StringProperty()
friends = RelationshipTo("Person", "FRIEND", model=FriendRel)
if __name__ == "__main__":
neomodel.config.DATABASE_URL = "bolt://<user>:<pass>@localhost:<port>"
jim = Person(name="Jim").save()
bob = Person(name="Bob").save()
rel = jim.friends.connect(bob, {"property_one": 1, "propertyTwo": 2, "property_three": 3})
print(f"property_one: {rel.property_one}, propertyTwo: {rel.propertyTwo}, property_three: {rel.property_three}")
Expected Behavior
Properties of
StructuredRel
relationships that are marked with adb_property
property name override are properly written to the database but skipped during inflation, and thus are always filled withNone
when returned from queries.Actual Behavior
Properties of
StructuredRel
relationships that are marked with adb_property
property name override should be filled from their value in the database during inflation.How to Reproduce the Problem
Create a
StructuredRel
with a property that usesdb_property
and attempt to round-trip the relationship to the database.Simple Example
Simple reproduction using slightly modified versions of objects from the example code:
prints:
The values do properly make it to the database:
And during inflation, the value is present in the
_properties
dict of the db object:Cause
This seems to be caused by
StructuredRel.inflate(...)
not considering thedb_property
field, and only checking the pythonkey
of the property:whereas
StructuredNode.inflate(...)
gives thedb_property
priority over thekey
:Specifications
Versions