Closed oliver-s-lee closed 1 year ago
Hey @oliver-s-lee,
thanks for reporting this issue! You are correct that using a+
will break TinyDB's JSON storage. For now I've added a warning to the API reference and a Python warning message when using an access mode that will probably lead to data loss or corruption. Throwing an exception however would probably be a breaking change that would necessitate a new major release of TinyDB so I'll that would have to come at some later point 🙂
Hi there, nice project!
I think I've come across a bug, which is pretty much described by the title. When a database is opened with
access_mode = "a+"
and theremove()
method of a table is called, the database file is partly duplicated (with the deleted records not appearing in the duplicate). This results in the database being unreadable.Simple test case:
I couldn't find much discussion of 'access_mode' in the docs, except for the API reference for the JSONStorage which states:
access_mode (str) – mode in which the file is opened (r, r+, w, a, x, b, t, +, U)
, which perhaps indicates that "a+" isn't an allowed option? If so it may be useful to stop with an exception in the constructor to prevent unexpected corruption further down the road.Cheers!