[Neo] bug in Node.delete() ?

Raul Raja Martinez raulraja at gmail.com
Wed Feb 10 17:23:40 CET 2010


I was thinking more in the line of
node.delete() //does not delete if there are relationships
node.delete(true) // deletes the node including relationships.
But again no big deal, is already good the way it is

2010/2/10 Mattias Persson <mattias at neotechnology.com>:
> Hmm, maybe I didn't answer your question... you were wondering about
> automatically deleting all relationships on a node in Node.delete()
> right? Well, I don't know if Neo4j will support that or not, but we
> made the decision not to have it since it's good to be as explicit as
> possible so that potential code bugs aren't hidden, but instead
> surfaces as early as possible.
>
> 2010/2/10 Mattias Persson <mattias at neotechnology.com>:
>> I don't think that's a very good idea to have as a default behaviour
>> since potentially the entire graph is interconnected (and that it
>> isn't just a tree structure), deleting one node could potentially
>> delete the entire database.
>>
>> We could however have some kind of utility where you specify criterias
>> to traverse and delete, but then again you could probably use the
>> traverser api for that.
>>
>> Does that make enough sense to you?
>>
>> 2010/2/10, Raul Raja Martinez <raulraja at gmail.com>:
>>> Any plans to support cascade deletion?
>>> We currently have some cases where we have to manually iterate over
>>> the relationships and remove them.
>>> Not a big deal because we wrap many other operations but something
>>> that would nice to have out of the box.
>>>
>>> 2010/2/9 Mattias Persson <mattias at neotechnology.com>:
>>>> Yep, that's right... The documentation is a bit unclear/untrue about
>>>> that. Ryan is right in that it's only checked when the transaction is
>>>> commited. This means that you can delete a node which has
>>>> relationships on it, just as long as you delete its relationships
>>>> before the transaction is committed.
>>>>
>>>> 2010/2/9, Ryan Levering <rrlevering at gmail.com>:
>>>>> Well, it's not totally untrue.  Try changing your tx.failure() to
>>>>> tx.success() and you'll get the error you're looking for.  Neo is a
>>>>> fairly
>>>>> transaction driven database and I imagine it doesn't check the
>>>>> constraints
>>>>> of the delete until it's committed.
>>>>>
>>>>> On Feb 9, 2010, at 3:28 PM, Stefan Armbruster wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> it looks like Node.delete() does not behave as defined in the API docs:
>>>>>> <quote>
>>>>>> Deletes this node if it has no relationships attached to it. If delete()
>>>>>> is invoked on a node with relationships, an unchecked exception will be
>>>>>> raised. Invoking any methods on this node after delete() has returned is
>>>>>> invalid and will lead to unspecified behavior.
>>>>>> </quote>
>>>>>>
>>>>>> I've created some sample code (http://pastebin.com/f2918f9d5)
>>>>>> demonstrating this. Line 25 tries to delete a node with a relationship
>>>>>> attached to it. There's no exception (as expected from the API docs) and
>>>>>> the node is still there afterwards. So delete() seems to do simply
>>>>>> nothing if there are any realtionships.
>>>>>>
>>>>>> Did I miss something or should we consider this a bug?
>>>>>>
>>>>>> Regards,
>>>>>> Stefan
>>>>>> _______________________________________________
>>>>>> Neo mailing list
>>>>>> User at lists.neo4j.org
>>>>>> https://lists.neo4j.org/mailman/listinfo/user
>>>>>
>>>>> _______________________________________________
>>>>> Neo mailing list
>>>>> User at lists.neo4j.org
>>>>> https://lists.neo4j.org/mailman/listinfo/user
>>>>>
>>>>
>>>>
>>>> --
>>>> Mattias Persson, [mattias at neotechnology.com]
>>>> Neo Technology, www.neotechnology.com
>>>> _______________________________________________
>>>> Neo mailing list
>>>> User at lists.neo4j.org
>>>> https://lists.neo4j.org/mailman/listinfo/user
>>>>
>>>
>>>
>>>
>>> --
>>> Raul Raja
>>> _______________________________________________
>>> Neo mailing list
>>> User at lists.neo4j.org
>>> https://lists.neo4j.org/mailman/listinfo/user
>>>
>>
>>
>> --
>> Mattias Persson, [mattias at neotechnology.com]
>> Neo Technology, www.neotechnology.com
>>
>
>
>
> --
> Mattias Persson, [mattias at neotechnology.com]
> Neo Technology, www.neotechnology.com
> _______________________________________________
> Neo mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Raul Raja


More information about the User mailing list