When using sub-fields contents in database are not updated

Bug #1157004 reported by Kevin Wright
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
U1DB Qt/ QML
Incomplete
Wishlist
Unassigned

Bug Description

When initially creating a document using the following:

    U1db.Document {
        id: aDocument
        database: aDatabase
        docId: 'hello'
        create: true
        defaults: { "hello": [{"value":"99 Hello Worlds on the wall...!"},{"value":"98 Hello Worlds on the wall...!"},{"value":"97 Hello Worlds on the wall...!"}] }
        }

The contents in the database contain the following.

{
    "hello": [
        {
            "value": "99 Hello Worlds on the wall...!"
        },
        {
            "value": "98 Hello Worlds on the wall...!"
        },
        {
            "value": "97 Hello Worlds on the wall...!"
        }
    ]
}

This is expected.

However, if and additional entry {"value":"...and so on..."} is added to the default property of the Document, as demonstrated by the following snippet:

defaults: { "hello": [{"value":"99 Hello Worlds on the wall...!"},{"value":"98 Hello Worlds on the wall...!"},{"value":"97 Hello Worlds on the wall...!"},{"value":"...and so on..."}] }

... the contents in the database remain the same as above, when they should be updated to:

{
    "hello": [
        {
            "value": "99 Hello Worlds on the wall...!"
        },
        {
            "value": "98 Hello Worlds on the wall...!"
        },
        {
            "value": "97 Hello Worlds on the wall...!"
        },
        {
            "value": "...and so on..."
        }
    ]
}

If one destroys the database file and adds in the additional entry to the default section as aboce then the database contents reflect the change. But when removing it again and running the application a second time the contents in database does not reflect the omission.

Revision history for this message
Cris Dywan (kalikiana) wrote :

This is what happens:
1. Define a document with defaults
2. The document is added to the database
3. Something *may* modify the document
4. Quit the application
5. New version with changed defaults
6. We can't know if the document's defaults have changed

So this is by design. Unless we special-case default-documents, circumvent the database, add an in-memory document storage, and prevent them from being written unless modified directly.

At the very best I think this is a low priority feature request.

Changed in u1db-qt:
importance: Critical → Wishlist
status: New → Incomplete
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.