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
=== modified file 'src/index.cpp'
--- src/index.cpp 2013-08-08 10:31:16 +0000
+++ src/index.cpp 2013-09-06 16:57:59 +0000
@@ -175,6 +175,9 @@
175 Q_FOREACH (QString docId, documents){175 Q_FOREACH (QString docId, documents){
176176
177 QVariant document = db->getDocUnchecked(docId);177 QVariant document = db->getDocUnchecked(docId);
178 // Skip empty aka deleted docs
179 if (!document.isValid())
180 continue;
178181
179 QStringList fieldsList;182 QStringList fieldsList;
180183
@@ -244,7 +247,7 @@
244 }247 }
245 }248 }
246249
247 if(results_map.count()>0){250 if(true){
248 QVariantMap mapIdResult;251 QVariantMap mapIdResult;
249 mapIdResult.insert("docId", docId);252 mapIdResult.insert("docId", docId);
250 mapIdResult.insert("result", results_map);253 mapIdResult.insert("result", results_map);
251254
=== modified file 'src/query.cpp'
--- src/query.cpp 2013-08-27 10:49:26 +0000
+++ src/query.cpp 2013-09-06 16:57:59 +0000
@@ -144,8 +144,8 @@
144 }144 }
145145
146 if(match == true){146 if(match == true){
147 // Results must be unique and not empty aka deleted147 // Results must be unique
148 if (!m_documents.contains(docId) && result_variant.isValid())148 if (!m_documents.contains(docId) && result.count()>0)
149 {149 {
150 m_documents.append(docId);150 m_documents.append(docId);
151 m_results.append(result);151 m_results.append(result);
152152
=== modified file 'tests/tst_query.qml'
--- tests/tst_query.qml 2013-08-27 10:49:26 +0000
+++ tests/tst_query.qml 2013-09-06 16:57:59 +0000
@@ -120,6 +120,55 @@
120 query: [{ 'name': 'Ivanka', 'phone': '*' }]120 query: [{ 'name': 'Ivanka', 'phone': '*' }]
121 }121 }
122122
123 U1db.Database {
124 id: tokusatsu
125 }
126
127 U1db.Document {
128 database: tokusatsu
129 docId: 'ooo'
130 contents: { 'series': 'ooo', 'type': 'rider' }
131 }
132
133 U1db.Document {
134 database: tokusatsu
135 docId: 'gokaiger'
136 contents: { 'series': 'gokaiger', 'type': 'sentai' }
137 }
138
139 U1db.Document {
140 id: tokusatsuDocumentWizard
141 docId: 'wizard'
142 contents: { 'series': 'wizard', 'type': 'rider',
143 'transformations': ['Flame Style','Water Style'] }
144 }
145
146 U1db.Document {
147 id: tokusatsuDocumentDino
148 docId: 'dino'
149 contents: { 'series': 'zyuranger', 'scarf': false, 'type': 'sentai',
150 'beasts': ['T-Rex', 'Mastodon'] }
151 }
152
153 U1db.Index {
154 id: bySeries
155 database: tokusatsu
156 name: 'by-series'
157 expression: ['series', 'type']
158 }
159
160 U1db.Query {
161 id: allHeroesWithType
162 index: bySeries
163 query: [{ 'series': '*' }, { 'type': '*' }]
164 }
165
166 U1db.Query {
167 id: allHeroesSeriesOnly
168 index: bySeries
169 query: [{ 'series': '*' }]
170 }
171
123 SignalSpy {172 SignalSpy {
124 id: spyDocumentsChanged173 id: spyDocumentsChanged
125 target: defaultPhone174 target: defaultPhone
@@ -163,6 +212,8 @@
163212
164 function test_2_numbers () {213 function test_2_numbers () {
165 // We should get '1'214 // We should get '1'
215 if(s12345Phone.documents != ['1'])
216 console.log('uno: ' + JSON.stringify(s12345Phone.documents))
166 compare(s12345Phone.documents, ['1'], 'uno')217 compare(s12345Phone.documents, ['1'], 'uno')
167 // It's okay to mix strings and numerical values218 // It's okay to mix strings and numerical values
168 compare(s12345Phone.documents, i12345Phone.documents, 'dos')219 compare(s12345Phone.documents, i12345Phone.documents, 'dos')
@@ -180,11 +231,39 @@
180 }231 }
181232
182 function test_4_delete () {233 function test_4_delete () {
234 // workaroundQueryAndWait(defaultPhone)
235 if(defaultPhone.documents != ['1', '_', 'a'])
236 console.log('uno: ' + JSON.stringify(defaultPhone.documents))
183 compare(defaultPhone.documents, ['1', '_', 'a'], 'uno')237 compare(defaultPhone.documents, ['1', '_', 'a'], 'uno')
184 // Deleted aka empty documents should not be returned238 // Deleted aka empty documents should not be returned
185 gents.putDoc('', '_')239 gents.putDoc('', '_')
240 workaroundQueryAndWait(defaultPhone)
241 if(defaultPhone.documents != ['1', 'a'])
242 console.log('dos: ' + JSON.stringify(defaultPhone.documents))
186 compare(defaultPhone.documents, ['1', 'a'], 'dos')243 compare(defaultPhone.documents, ['1', 'a'], 'dos')
187 }244 }
188245
246 function test_5_definition () {
247 workaroundQueryAndWait(allHeroesWithType)
248 compare(allHeroesWithType.documents, ['gokaiger', 'ooo'], 'ichi')
249 workaroundQueryAndWait(allHeroesSeriesOnly)
250 compare(allHeroesWithType.documents, allHeroesSeriesOnly.documents, 'ni')
251 // Add a document with extra fields
252 tokusatsu.putDoc(tokusatsuDocumentWizard.contents, tokusatsuDocumentWizard.docId)
253 workaroundQueryAndWait(allHeroesWithType)
254 compare(allHeroesWithType.documents, ['gokaiger', 'ooo', 'wizard'], 'san')
255 // workaroundQueryAndWait(allHeroesSeriesOnly)
256 compare(allHeroesWithType.documents, allHeroesSeriesOnly.documents, 'chi')
257 // Add a document with mixed custom fields
258 tokusatsu.putDoc(tokusatsuDocumentDino.contents, tokusatsuDocumentDino.docId)
259 workaroundQueryAndWait(allHeroesWithType)
260 console.log('allDocs: ' + JSON.stringify(tokusatsu.listDocs()))
261 if(allHeroesWithType.documents != ['dino', 'gokaiger', 'ooo', 'wizard'])
262 console.log('go: ' + JSON.stringify(allHeroesWithType.documents))
263 compare(allHeroesWithType.documents, ['dino', 'gokaiger', 'ooo', 'wizard'], 'go')
264 // workaroundQueryAndWait(allHeroesSeriesOnly)
265 compare(allHeroesWithType.documents, allHeroesSeriesOnly.documents, 'roku')
266 }
267
189} }268} }
190269

Subscribers

People subscribed via source and target branches

to all changes: