giuspen / cherrytree

cherrytree
https://www.giuspen.net/cherrytree/
Other
3.31k stars 456 forks source link

UNIQUE constraint failed: children.node_id, after creating a subnode #2377

Open sylvainfaivre opened 9 months ago

sylvainfaivre commented 9 months ago

CherryTree 1.0.2 Ubuntu 23.04

After creating a subnode for a specific node, when trying to save, I get the error :

!! sqlite3_step: UNIQUE constraint failed: children.node_id

This is with a file I've been maintaining for years, so some of the contents might be corrupt.

By the way, while trying to edit the file to redact sensitive data, I tried saving the file as a new file, and I then noticed that this problem does not happen with the new file. Does the "save as" function not use the same code as the "save" function ?

@giuspen I can share the file privately to you, how should I do this ?

(this issue is partly related to #2367)

giuspen commented 9 months ago

Hi @sylvainfaivre the 'save as' is regenerating a completely new database while the 'save' is only updating the part that you modified, so the save relies on the past. A 'save as' is also regenerating all the node IDs starting from 1. You can send me the misbehaving database via email (see help--about) and explain what to do to reproduce the issue

sylvainfaivre commented 8 months ago

[The following has been copied and pasted from an email I just sent]

Hi,

Sorry it took me so long.

I found a way to remove most data in the file, "save and vacuum", and still experience faulty behaviour. You will find the file attached to this message.

If you add a subnode to the "rabbitMQ" node and save the file, you will get the error « UNIQUE constraint failed: children.node_id » Same error after adding a subnode to some other nodes, like the 8 or 9 lowest nodes in the file.

Two bizarre things I saw in the SQL dump for this file :

Anyway, don't worry too much about this, it's probably a result of some kind of corruption that happened with an older release, and cannot happen in current releases, plus I can fix the file by using the "save as" function.

But thanks for looking into it anyway :-)

Cheers, Sylvain