Top-level fields in document cannot be indexed

Bug #1271972 reported by Stuart Langridge on 2014-01-23
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
U1DB Qt/ QML
High
Unassigned
u1db-qt (Ubuntu)
Undecided
Unassigned

Bug Description

An index defined on a field at the root of a U1db.Document will contain no data.

Example code below. It shows the results of two U1Db.Query/Indexes, one of which is on a top-level field in the document and the other not. The one on the top-level field does not work.

import QtQuick 2.0
import U1db 1.0 as U1db

Rectangle {
    width: 600
    height: 300

    U1db.Database { id: db; path: "u1db-broken-query"; }
    U1db.Document {
        database: db; docId: "doc1"; create: true
        defaults: { "topfield": { "subfield": "subvalue1" }, "toplevelfield": "topvalue1" }
    }
    U1db.Document {
        database: db; docId: "doc2"; create: true
        defaults: { "topfield": { "subfield": "subvalue2" }, "toplevelfield": "topvalue2" }
    }
    U1db.Index {
        database: db
        id: by_topfield_subfield
        expression: ["topfield.subfield"]
    }
    U1db.Index {
        database: db
        id: by_toplevelfield
        expression: ["toplevelfield.subfield"]
    }
    U1db.Query { id: qtopsub; index: by_topfield_subfield; query: [{subfield: "*"}] }
    U1db.Query { id: qtoplevel; index: by_toplevelfield; query: [{toplevelfield: "*"}] }

    Text {
        id: h1
        width: parent.width / 2
        height: 50
        anchors.left: parent.left
        anchors.top: parent.top
        horizontalAlignment: Text.AlignHCenter
        text: "ListModel on topfield.subfield"
    }

    ListView {
        anchors.top: h1.bottom
        anchors.left: parent.left
        width: h1.width
        anchors.bottom: parent.bottom
        model: qtopsub
        delegate: Text {
            text: JSON.stringify(model.contents)
        }
    }

    Text {
        id: h2
        width: parent.width / 2
        height: 50
        anchors.right: parent.right
        anchors.top: parent.top
        horizontalAlignment: Text.AlignHCenter
        text: "ListModel on toplevelfield"
    }

    ListView {
        anchors.top: h2.bottom
        anchors.right: parent.right
        width: h2.width
        anchors.bottom: parent.bottom
        model: qtoplevel
        delegate: Text {
            text: JSON.stringify(model.contents)
        }
    }
}

Related branches

Changed in u1db-qt:
status: New → Confirmed
importance: Undecided → High
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: Confirmed → 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
David Planella (dpm) on 2014-06-12
Changed in u1db-qt:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers