Closed tonjo closed 11 years ago
Good catch. neo4django.db.models.script_utils.LazyNode
is a subclass of neo4jrestclient's Node
that only pulls data from its initial representation, instead of every time a property is read. I'll try to look into this soon.
Any news about this ?
Cheers
Hi, I Just came back, I hope in a few days I will have some time. Thanks for the patience. Il giorno 01/ago/2013 18:31, "Pierre Romera" notifications@github.com ha scritto:
Any news about this ?
Cheers
— Reply to this email directly or view it on GitHubhttps://github.com/scholrly/neo4django/issues/199#issuecomment-21949427 .
Relationship .remove works ONLY when related node is just created, not when recalling a previously defined one. (That's why unit test don't fail)
I consider it a crucial issue.
Inside the remove method, the problem is rels_by_node[obj.node] returns [] because when the node "obj" is recalled through get or get_or_create, obj.node is a neo4jrestclient.client.LazyNode, not a neo4jrestclient.client.Node. When it is created it's a Node instead.
Creating a node:
But when I search for the very same Node:
Printing out rels_by_node:
key: < Neo4j Node: http://localhost:7474/db/data/node/50 > value: [ < Neo4j Relationship: http://localhost:7474/db/data/relationship/89 > ] key: < Neo4j Node: http://localhost:7474/db/data/node/44 > value: [ < Neo4j Relationship: http://localhost:7474/db/data/relationship/79 > ] key: < Neo4j LazyNode: http://localhost:7474/db/data/node/50 > value: []
The FIRST row is the one giving the relationship, but is the last one found, because of LazyNode.
From row 730 in relationships.py: for obj in objs: candidate_rels = rels_by_node[obj.node] if hasattr(obj, 'node') else []
It will be empty if obj.node is LazyNode
I wish I can help more, but I'm not sure what a LazyNode is ;) I don't know exactly where to touch.