iOS Couchbase lite via CBLIncrementalStore

Hi all,

I want to use Couchbase lite as my database in an iOS app. CBLIncrementalStore is great since I can keep my Core Data layer as is :wink:

BUT, I have a problem with it. With CBLIncrementalStore, all NSFetchResultsController (FRC) are not fully functional. FRCs used with a predicate that filters on relationships doesn’t return anything. More details:

  • Take Couchbase’s sample code called Recipes
  • add a NSPredicate on recipes filtering on a recipeType
    -> the request doesn’t return anything.

So I tried the 1.1 version of couchbase lite by taking the same project and adding the new framwork files and the new CBLIncrementalStore but now the app doesn’t work anymore (the list of recipes is empty).
I tried on my project that worked with 1.0 and the app crashes with this crash log:

CoreData: error: -addPersistentStoreWithType:CBLIncrementalStore configuration:(null) URL:file:///Users/florion/Library/Developer/CoreSimulator/Devices/BB6F7BB0-B1EF-4C7A-898A-61E1310B90B6/data/Containers/Data/Application/B005D3AE-DB85-4261-989F-96C6390500C8/Library/Application%20Support/myApp/database694.sqlite options:{
    NSInferMappingModelAutomaticallyOption = 1;
    NSMigratePersistentStoresAutomaticallyOption = 1;
} ... returned error Error Domain=CBLISErrorDomain Code=6 "Could not create database" UserInfo=0x786aa5a0 {NSUnderlyingError=0x786ab970 "400 Invalid database/document/revision ID", NSLocalizedDescription=Could not create database} with userInfo dictionary {
    NSLocalizedDescription = "Could not create database";
    NSUnderlyingError = "Error Domain=CBLHTTP Code=400 \"400 Invalid database/document/revision ID\" UserInfo=0x786ab120 {NSLocalizedFailureReason=Invalid database/document/revision ID, NSLocalizedDescription=400 Invalid database/document/revision ID}";

Am I doing something wrong ?
Thanks :wink:

When you got the error, did the app already have an existing database from 1.0.4? If so this could be a bug in our database upgrade code in 1.1, so we should look into it immediately.

Could you send me a copy of the database file? It’s database694.sqlite, at the path given in the log you pasted above. You can email it to jens at couchbase. Thanks!

I think the database694.sqlite is the name referenced by CoreData. The correct database file name would be database694.cblite.

I must have done something wrong since my coworker made it work, without anything special… Sorry, and thanks ! :slight_smile:

THOUGH, something is still not functional with NSFetchResultsControllers and relationships in 1.1. The request doesn’t return anything with a predicate on a relationship of a relationship. For example, with a request [NSPredicate predicateWithFormat:@“someRelationship.someOtherRelationship == %@”, someStuff]

Have you noticed something similar ?

Glad to hear that there is no issues.

Is that querying a nested relationship? Is the destination relationship (someOtherRelationship) is 1-1? Could you provide a little more info about the entities so I can create a unit test to check the issue?

CBLIncrementalStore v1.1 supports at least basic relationship queries for both 1-1 and 1-many. As join queries are complicated, there might be a bug or leave out some cases.

We added a unit test on couchbase-lite-ios repository to reproduce this bug, have you seen it ?

I mean I did a pull request on the repository.
Here :