scholrly / neo4django

Drop-in Neo4j/Django integration.
GNU General Public License v3.0
357 stars 83 forks source link

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

Closed tonjo closed 10 years ago

tonjo commented 11 years ago

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 ;)

mhluongo commented 11 years ago

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

mhluongo commented 11 years ago

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.

tonjo commented 11 years ago

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 ;)

mhluongo commented 11 years ago

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

tonjo commented 10 years ago

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.