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

Bug #1266478 reported by Nekhelesh Ramananthan on 2014-01-06
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Ubuntu Music App
u1db-qt (Ubuntu)

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

Nekhelesh Ramananthan (nik90) wrote :

Here is a sample test program which indicates the issue.

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.

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.

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.

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!

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) on 2014-02-04
Changed in music-app:
status: New → Triaged
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
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  Edit
Everyone can see this information.

Other bug subscribers