scholrly / neo4django

Drop-in Neo4j/Django integration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

n=MyNode(id=someID) and n.save() overwrite existing node

tonjo opened this issue · comments

Weird behaviours:
Suppose we have model GenericPerson with name attribute and
Man(GenericPerson), Woman(GenericPerson) 2 subclasses.

If I do
w=Woman(name='Amy')
w.save()

and after
m=Man(id=w.id) # giving id (no reasons to do this)
actually it finds Amy (m.name=='Amy')
m.save() # gender change without surgeon ;)

Haha, interesting behavior! I have a feeling it also left the type tree in a weird state... flagging this as a bug.

While this is a bug, a quick note - the intended behavior is that the model shouldn't be allowed to be created with a preset id at all, since Neo4j doesn't allow developer to decide node ids a priori.

Another weird thing is that sometimes (can't replicate always)
doing m=Man(id=w.id) it will "find" the node with that existing id.

Maybe this could help in debugging...

PS: I know there are no reasons to do that,
I was just trying to see what came out. A bug ;)

I'll move this to the next milestone- it's definitely confusing behavior regardless :)

It "was" a django issue, not neo4django's.
Trying the same with a django.db.models.Model give the same result.
But I'm using django 1.5, I don't know if they corrected in earlier versions.