Comment 5 for bug 1243395

Revision history for this message
Kevin Wright (kevin-wright-1) wrote :

Having an empty document as a delegate of the ListView should be expected behaviour, if the document in the model is empty. However, a deleted document and empty document are not the same thing.

The original high level API documentation for U1DB states: "Mark a document as deleted. Will abort if the current revision doesn’t match doc.rev. This will also set doc.content to None."

It appears that in the reference implementation (in Python) a blank or empty document is still represented as an empty JSON string "{}", while a deleted document has contents that are stored as completly empty (aka the 'None' mentioned above).

There isn't anything else to "mark a document as deleted", and in fact the document still exists in the database -- it is never truly deleted or removed 100%.

The only difference between a (pseudo-)deleted document and a document with no content is that the former has lost the attribute 'content' at the Python level, while the latter still has that attribute (it is simply an empty JSON object).

Adding a boolean property to the Document class called "delete", set to false by default, which will empty the content in the underlying database (the SQLite database behind the scene), would be a very declarative approach to deleting documents.

When it comes to suppressing Documents with no content (aka "deleted"), it might not be possible to remove the 'contents' attribute at runtime. This leaves only checking if the contents are blank (but not simply an empty JSON string).

As for when and where those documents should be filtered out, i.e. in what class that functionality should exist, perhaps it is a matter of opinion, but it still seems to me that Query or Index are the appropriate places to filter out "deleted" documents and maybe even blank documents too, with an appropriate attribute. It may be the case that people want a list of deleted/blank documents, and removing the ability to get that information would then be undesireable.

Database could (and maybe should) have a default Query and Index pair, which the developer can access to modify the state for suppressing "deleted" documents (and again perhaps blank ones).

A dedicated UI component for use with U1Db-Qt could also offer some potential for complimenting the plugin itself, and offer another opportunity to add feature requests appropriate to the more declarative approach.