neo4j-contrib / neomodel

An Object Graph Mapper (OGM) for the Neo4j graph database.
https://neomodel.readthedocs.io
MIT License
936 stars 231 forks source link

Unable to access property values on nodes that inherit from SemiStructuredNode #779

Closed krashr-ds closed 7 months ago

krashr-ds commented 7 months ago

Expected Behavior (Mandatory)

Hello!

I have a series of classes that inherit from SemiStructuredNode.

They work great, until I try to access properties on the nodes.

I can bring back a list of nodes with list_of_nodes = SourceObject.nodes.all()

When I iterate over the nodes, I expect to be able to see the VALUES of properties when I access them, for example, I expect:

for so in list_of_nodes: print(so.name)

to print the VALUES of the name properties of the SourceObject nodes in the list.

Actual Behavior (Mandatory)

That doesn't happen! Instead, I get a series of property references, like this:

<neomodel.properties.StringProperty object at 0x000001A6AF356C40> <neomodel.properties.StringProperty object at 0x000001A6AF356610> <neomodel.properties.StringProperty object at 0x000001A6AF356610>

How to Reproduce the Problem

Create a python program, like so:

import neomodel from neomodel import config, Traversal from lib.cs_models import SourceObject, SourceExpression

try: config.DATABASE_URL = "bolt://neo4j:yourpassword@localhost:7687" except: raise Exception("Unable to connect to Neo4j test db.") finally: print("Neo4j TEST connection established.")

get SourceObjects

source_objects = SourceObject.nodes.all() for so in source_objects:

print(so.SourceObjectName)

RESULTS:

Neo4j TEST connection established. <neomodel.properties.StringProperty object at 0x000001EEEA85EA60> <neomodel.properties.StringProperty object at 0x000001EEEA85EA60> <neomodel.properties.StringProperty object at 0x000001EEEA85EA60>

SPECS:

Windows 10 PC IDE: Spyder Conda env Python version: Python 3.9.17 Neomodel version: 5.2.1

Please let me know if I'm doing something wrong here!

Thanks.

krashr-ds commented 7 months ago

Ok, so I figured this out. It has to do with super constructors being called at every level, regardless. Thanks!