← Back to team overview

ubuntu-sdk-bugs team mailing list archive

[Bug 1271972] Re: Top-level fields in document cannot be indexed

 

** Changed in: u1db-qt
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
SDK bug tracking, which is subscribed to u1db-qt in Ubuntu.
https://bugs.launchpad.net/bugs/1271972

Title:
  Top-level fields in document cannot be indexed

Status in U1DB Qt/ QML:
  Fix Released
Status in “u1db-qt” package in Ubuntu:
  Fix Released

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)
          }
      }
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/u1db-qt/+bug/1271972/+subscriptions