Chris Klingler
Chris Klingler

Reputation: 5296

Couchbase Lite 1.1.0-31 LiveQuery Has All Rows But All Documents NULL

been loving using Couchbase in my iOS and Android projects to create Couch documents and replicate them to remote servers. Unfortunately I've run in to a bit of a snag recently since updating to the newest version of Couchbase Lite.

Before my most recent update, I would set up my manager and database and then call initializeQuery the following would have pulled all the docs from the db with their data intact where I could see the documentID and data in each doc (double checking the database I see all the docs are still there and they all have the key type set with a string): (Code posted in Objective C, though seeing similar results with Swift/Android)

 - (void) initializeQuery {
     CBLQuery* query = [_database createAllDocumentsQuery];
     liveQuery = query.asLiveQuery;
     [liveQuery addObserver: self forKeyPath: @"rows" options: 0 context: NULL];
     [liveQuery start];
 }

 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
     if (object == liveQuery) {

         CBLQueryEnumerator *result = liveQuery.rows;

         NSLog(@"No. 1 - number of rows is %lu", (unsigned long)result.count);

         for (CBLQueryRow *row in result) {
              NSLog(@"No. 2 - what is each row's doc ID: %@", row.documentID);
              NSLog(@"No. 3 - what is each row's document %@", row.document);
         }
     }
 }

Now (since updating to the newest Couchbase Lite) I still get the correct number of rows (on NSLog No. 1), and get all the right docIds (on NSLog No. 2) but each row's document is now (null) (on NSLog No. 3) and all keys/values do not exist. Can anyone explain to me if I need to change something to get my data to remain intact all the way to the end. If so a poor Idaho programmer will owe you a life debt! (Not worth much it is true, but it is all I have to give)

Upvotes: 1

Views: 281

Answers (1)

Chris Klingler
Chris Klingler

Reputation: 5296

This error only appeared to happen with allDocument, asynchronous queries and was previously found and addressed by the Couchbase Lite devs here: https://github.com/couchbase/couchbase-lite-ios/issues/755 and was fixed in build 1.1.1, available here: http://latestbuilds.hq.couchbase.com/couchbase-lite-ios/release/1.1.1/

So if you see this issue check for an update and move from 1.1.0 to 1.1.1. After doing so everything is puppies, unicorns and rainbows!

Upvotes: 0

Related Questions