Top-level fields in document cannot be indexed
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
U1DB Qt/ QML |
Fix Released
|
High
|
Unassigned | ||
u1db-qt (Ubuntu) |
Fix Released
|
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-
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_
expression: ["topfield.
}
U1db.Index {
database: db
id: by_toplevelfield
expression: ["toplevelfield
}
U1db.Query { id: qtopsub; index: by_topfield_
U1db.Query { id: qtoplevel; index: by_toplevelfield; query: [{toplevelfield: "*"}] }
Text {
id: h1
width: parent.width / 2
height: 50
text: "ListModel on topfield.subfield"
}
ListView {
width: h1.width
model: qtopsub
delegate: Text {
text: JSON.stringify(
}
}
Text {
id: h2
width: parent.width / 2
height: 50
text: "ListModel on toplevelfield"
}
ListView {
width: h2.width
model: qtoplevel
delegate: Text {
text: JSON.stringify(
}
}
}
Related branches
- Benjamin Zeller: Approve
- PS Jenkins bot: Approve (continuous-integration)
-
Diff: 849 lines (+195/-488)7 files modifiedexamples/CMakeLists.txt (+1/-1)
examples/bookmarks/bookmarks.qml (+131/-450)
examples/u1db-qt-example-4/u1db-qt-example-4.qdoc (+0/-24)
src/index.cpp (+6/-2)
src/query.cpp (+16/-8)
src/query.h (+2/-2)
tests/tst_query.qml (+39/-1)
Changed in u1db-qt: | |
status: | New → Confirmed |
importance: | Undecided → High |
Changed in u1db-qt: | |
status: | Fix Committed → Fix Released |
Fix committed into lp:u1db-qt at revision 112, scheduled for release in u1db-qt, milestone 1.0