Query model doesn't work properly with a multilevel document list

Bug #1266478 reported by Nekhelesh Ramananthan
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Fix Committed
Ubuntu Music App
u1db-qt (Ubuntu)
Fix Released

Bug Description

While using a Query model in a listview, I have noticed a weird scenario where it happens to kick out some index fields. Here is the code I used. Starting of with the document, index and query definitions,

U1db.Document {
        database: appDb
        docId: 'eyeOfTheTiger'
        create: true
        defaults: { "playlist": { "name": "oldies", "tracks": [ { "file": "old1", "title": "very old song" },{ "file": "old2", "title": "even older" } ] } }

        database: appDb
        id: by_playlist
        expression: ["playlist.name", "playlist.tracks.file", "playlist.tracks.title"]

        id: aQuery
        index: by_playlist
        query: [{"name":"*"}, {"file":"*"}, {"title":"*"}]

Here below is the listview where this query model is used.

ListView {
            id: playlistView

            model: aQuery
            clip: true
            spacing: units.gu(2)
            anchors {
                left: parent.left
                top: parent.top
                right: parent.right
                bottom: addButton.top
                margins: units.gu(2)

            delegate: Item {
                width: parent.width
                height: childrenRect.height

                Column {
                    Text { text: contents.name }
                    Text { text: contents.file + "|" + contents.title }

On running the program, I get the output referring to contents.name as undefined.
Unable to assign [undefined] to QString

Here is the strange part, If I change the index expression to ["playlist.name", "playlist.tracks"], then contents.name seems to be properly displayed. However now we lose the playlist.tracks field. This only happens when there are multiple layer lists in a document. If they are on the same level, it seems to work fine.

Related branches

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Here is a sample test program which indicates the issue.

Revision history for this message
Joshua Gleitze (joshua-gleitze) wrote :

I think this may be related to https://bugs.launchpad.net/u1db-qt/+bug/1215898 or even be caused by the same issue.

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Joshua, I think you may be correct. However I suggest that we wait for the merge proposal https://code.launchpad.net/~uonedb-qt/u1db-qt/ordering2/+merge/184350 to land in the PPA. If it solves this bug we mark it as a duplicate of your bug, else this is a different issue.

As a side note, try running example 5 again without any modifications. I now get a different output to the one you got :). I get only the first 3 entries. The others are missing unlike what you saw.

Revision history for this message
David Planella (dpm) wrote :

I've been hinted that this affects the Ability to sync playlists in the Music app, thus adding a bug task to keep track of that.

Revision history for this message
David Planella (dpm) wrote :

@Music app devs, could you provide some more context as to how exactly the Music app is affected by this bug and set the Importance field for it? Thanks!

Revision history for this message
Andrew Hayzen (ahayzen) wrote :

This is required for the implementation of playlists within the music-app.

The following structure is currently used:

    "playlist": {
        "name": "test",
        "tracks": [
            {"file": "abc", "title": "A"},
            {"file": "def", "title": "D"}

However using an index with an expression of ["playlist.name", "playlist.tracks.file", "playlist.tracks.title"] or ["playlist.name", "playlist.tracks"] doesn't work as expected, as stated in the bug description.

Changed in music-app:
importance: Undecided → Medium
Andrew Hayzen (ahayzen)
Changed in music-app:
status: New → Triaged
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

Fix committed into lp:u1db-qt at revision 112, scheduled for release in u1db-qt, milestone 1.0

Changed in u1db-qt:
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package u1db-qt - 0.1.5+14.04.20140313-0ubuntu1

u1db-qt (0.1.5+14.04.20140313-0ubuntu1) trusty; urgency=low

  [ CI bot ]
  * No change rebuild against Qt 5.2.1.

  [ Christian Dywan ]
  * Adopt xvfb.sh script from ui toolkit to run tests
  * Sort out build warnings and make them always fatal.
  * Implement Database.removeDoc method and use it in unit test
    Functionally this is equivalent to replacing the doc with an empty
    one. (LP: #1243395)
  * Use new-style qmlrunner log option to enable stdout.
  * Query improvements and more advanced example. (LP: #1271977,
    #1271972, #1266478)
  * Store whole document contents in the results and unit test that.
    (LP: #1271973)
  * Reverse query logic to check non-matching and internally convert
    between query syntaxes. (LP: #1284194, #1214538, #1215898)
  * Revert r113 and update unit test to verify previous behavior
 -- Ubuntu daily release <email address hidden> Thu, 13 Mar 2014 23:12:40 +0000

Changed in u1db-qt (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers