Merge lp:~uonedb-qt/u1db-qt/ordering2 into lp:u1db-qt

Proposed by Cris Dywan
Status: Rejected
Rejected by: Cris Dywan
Proposed branch: lp:~uonedb-qt/u1db-qt/ordering2
Merge into: lp:u1db-qt
Diff against target: 145 lines (+85/-3)
3 files modified
src/index.cpp (+4/-1)
src/query.cpp (+2/-2)
tests/tst_query.qml (+79/-0)
To merge this branch: bzr merge lp:~uonedb-qt/u1db-qt/ordering2
Reviewer Review Type Date Requested Status
U1DB Qt developers Pending
Review via email: mp+184350@code.launchpad.net

Commit message

Unit test query bugs related to the ordering of fields

To post a comment you must log in.

Unmerged revisions

107. By Cris Dywan

Failed attempt to fix ordering (WIP)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/index.cpp'
2--- src/index.cpp 2013-08-08 10:31:16 +0000
3+++ src/index.cpp 2013-09-06 16:57:59 +0000
4@@ -175,6 +175,9 @@
5 Q_FOREACH (QString docId, documents){
6
7 QVariant document = db->getDocUnchecked(docId);
8+ // Skip empty aka deleted docs
9+ if (!document.isValid())
10+ continue;
11
12 QStringList fieldsList;
13
14@@ -244,7 +247,7 @@
15 }
16 }
17
18- if(results_map.count()>0){
19+ if(true){
20 QVariantMap mapIdResult;
21 mapIdResult.insert("docId", docId);
22 mapIdResult.insert("result", results_map);
23
24=== modified file 'src/query.cpp'
25--- src/query.cpp 2013-08-27 10:49:26 +0000
26+++ src/query.cpp 2013-09-06 16:57:59 +0000
27@@ -144,8 +144,8 @@
28 }
29
30 if(match == true){
31- // Results must be unique and not empty aka deleted
32- if (!m_documents.contains(docId) && result_variant.isValid())
33+ // Results must be unique
34+ if (!m_documents.contains(docId) && result.count()>0)
35 {
36 m_documents.append(docId);
37 m_results.append(result);
38
39=== modified file 'tests/tst_query.qml'
40--- tests/tst_query.qml 2013-08-27 10:49:26 +0000
41+++ tests/tst_query.qml 2013-09-06 16:57:59 +0000
42@@ -120,6 +120,55 @@
43 query: [{ 'name': 'Ivanka', 'phone': '*' }]
44 }
45
46+ U1db.Database {
47+ id: tokusatsu
48+ }
49+
50+ U1db.Document {
51+ database: tokusatsu
52+ docId: 'ooo'
53+ contents: { 'series': 'ooo', 'type': 'rider' }
54+ }
55+
56+ U1db.Document {
57+ database: tokusatsu
58+ docId: 'gokaiger'
59+ contents: { 'series': 'gokaiger', 'type': 'sentai' }
60+ }
61+
62+ U1db.Document {
63+ id: tokusatsuDocumentWizard
64+ docId: 'wizard'
65+ contents: { 'series': 'wizard', 'type': 'rider',
66+ 'transformations': ['Flame Style','Water Style'] }
67+ }
68+
69+ U1db.Document {
70+ id: tokusatsuDocumentDino
71+ docId: 'dino'
72+ contents: { 'series': 'zyuranger', 'scarf': false, 'type': 'sentai',
73+ 'beasts': ['T-Rex', 'Mastodon'] }
74+ }
75+
76+ U1db.Index {
77+ id: bySeries
78+ database: tokusatsu
79+ name: 'by-series'
80+ expression: ['series', 'type']
81+ }
82+
83+ U1db.Query {
84+ id: allHeroesWithType
85+ index: bySeries
86+ query: [{ 'series': '*' }, { 'type': '*' }]
87+ }
88+
89+ U1db.Query {
90+ id: allHeroesSeriesOnly
91+ index: bySeries
92+ query: [{ 'series': '*' }]
93+ }
94+
95 SignalSpy {
96 id: spyDocumentsChanged
97 target: defaultPhone
98@@ -163,6 +212,8 @@
99
100 function test_2_numbers () {
101 // We should get '1'
102+ if(s12345Phone.documents != ['1'])
103+ console.log('uno: ' + JSON.stringify(s12345Phone.documents))
104 compare(s12345Phone.documents, ['1'], 'uno')
105 // It's okay to mix strings and numerical values
106 compare(s12345Phone.documents, i12345Phone.documents, 'dos')
107@@ -180,11 +231,39 @@
108 }
109
110 function test_4_delete () {
111+ // workaroundQueryAndWait(defaultPhone)
112+ if(defaultPhone.documents != ['1', '_', 'a'])
113+ console.log('uno: ' + JSON.stringify(defaultPhone.documents))
114 compare(defaultPhone.documents, ['1', '_', 'a'], 'uno')
115 // Deleted aka empty documents should not be returned
116 gents.putDoc('', '_')
117+ workaroundQueryAndWait(defaultPhone)
118+ if(defaultPhone.documents != ['1', 'a'])
119+ console.log('dos: ' + JSON.stringify(defaultPhone.documents))
120 compare(defaultPhone.documents, ['1', 'a'], 'dos')
121 }
122
123+ function test_5_definition () {
124+ workaroundQueryAndWait(allHeroesWithType)
125+ compare(allHeroesWithType.documents, ['gokaiger', 'ooo'], 'ichi')
126+ workaroundQueryAndWait(allHeroesSeriesOnly)
127+ compare(allHeroesWithType.documents, allHeroesSeriesOnly.documents, 'ni')
128+ // Add a document with extra fields
129+ tokusatsu.putDoc(tokusatsuDocumentWizard.contents, tokusatsuDocumentWizard.docId)
130+ workaroundQueryAndWait(allHeroesWithType)
131+ compare(allHeroesWithType.documents, ['gokaiger', 'ooo', 'wizard'], 'san')
132+ // workaroundQueryAndWait(allHeroesSeriesOnly)
133+ compare(allHeroesWithType.documents, allHeroesSeriesOnly.documents, 'chi')
134+ // Add a document with mixed custom fields
135+ tokusatsu.putDoc(tokusatsuDocumentDino.contents, tokusatsuDocumentDino.docId)
136+ workaroundQueryAndWait(allHeroesWithType)
137+ console.log('allDocs: ' + JSON.stringify(tokusatsu.listDocs()))
138+ if(allHeroesWithType.documents != ['dino', 'gokaiger', 'ooo', 'wizard'])
139+ console.log('go: ' + JSON.stringify(allHeroesWithType.documents))
140+ compare(allHeroesWithType.documents, ['dino', 'gokaiger', 'ooo', 'wizard'], 'go')
141+ // workaroundQueryAndWait(allHeroesSeriesOnly)
142+ compare(allHeroesWithType.documents, allHeroesSeriesOnly.documents, 'roku')
143+ }
144+
145 } }
146

Subscribers

People subscribed via source and target branches

to all changes: