Re: Multiple retired users with same name prevent import/export of db.
"John P. Rouillard" <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Ralf: In message <[email protected]>, Ralf Schlatterbeck writes: >On Sun, Jun 06, 2021 at 03:21:27PM -0400, John P. Rouillard wrote: >> 1. Import could read an entire csv and sort properly (taking >> possibly a large amount of memory). Not a great idea IMO. >> >> 2. Could it be handled when the exception is triggered? When the >> exception is trigered, changing the non-retired index entry from >> (key1, 0) to (key1, -1). Then retry the failing insert. > >How about inserting everything first with retired = -1 (instead of 0) That would require changing the sql definition for the index. We could disable the index during the import and perform an insert I guess. Currently the rdbms backends enforce uniqueness on (username, __retired__) by the rdbms index and not in python code. Currently the index automatically sets __retired__ to 0 as the default whenever a new node is added. In anydbm the problem doesn't occur. Anydbm doesn't have any mechanism for uniqueness afaik. Assuming there is a uniqueness constraint implemented when using anydbm, I believe it has to be implemented in python and not inside the db. >and then use 'restore' if the item is not retired (hopefully setting >the retired flag to 0) and using retire if retired (hopefully setting >the retired flag to the id). This maybe needs some relaxing of constraints >on import (and for retire) but probably would work because at every >point there is only one entry with retired=-1 in the db. This could work but we would need to change the sql index definiton to use a default of -1 and everywhere we add a new entry/node we would need to set the retired metadata. This is an alternate way of setting __retired__ on node creation and is what I meant by: 3. The code could be rewritten to set the __retired__ property on initial node creation, but that looks to be pretty invasive. You would have to update the retired property on every node creation since the database layer would create every node as retired (-1) rather than active (0). I do have some code that traps an exception from the addnode() call and tries todo the fixup using -1. It is testing ok for me. Can you take a look when I push it in a couple of hours. -- -- rouilj John Rouillard =========================================================================== My employers don't acknowledge my existence much less my opinions.