>From what I see, documentID is a readonly property of CBLDocument, and it
doesn't seem to ever be manipulated in the class. It is passed in on
initialization, so is there any chance that you created a CBLDocument with
a nil docID?
CBLDocuments are cached, so perhaps you are getting a zombie CBLDocument
from a document that has been evicted from the cache? You sure there is no
way to for this method to be called with a dealloc'd CBLDocument that is
still floating around?
On Sunday, May 18, 2014 8:50:38 AM UTC-7, Pascal wrote:
>
> I have the following class method, which returns a CBLQuery scoped to a
> given document. It does that by emitting a document-id first, ordering by
> that key and setting start- and stop-keys.
>
> Now I have received a handful of crash reports from Crashlytics where this
> method crashes when I set the start key to a nil document ID. I cannot
> reproduce the crash as the method should only ever be called for a document
> that has been stored in the database already. So before I go nuts trying to
> figure out when this happens, could it be that Couchbase unsets the
> document's `documentID` in certain scenarios? Thanks!
>
> + (CBLQuery *)resultsByDateForDocument:(CBLDocument *)document
>
> {
>
> NSParameterAssert(document);
>
> CBLView* view = [document.database viewNamed:@"patientResultsByDate"];
>
> if (!view.mapBlock) {
>
> [view setMapBlock:MAPBLOCK({
>
> if ([@"result" isEqualToString:doc[@"type"]]) {
>
> emit(@[doc[@"patient"], doc[@"date"] ?: [[NSDate new]
> med_isoRepresentation]], doc[@"_id"]);
>
> }
>
> }) version: @"2"];
>
> }
>
> NSString *docID = document.documentID; // if this is nil...
>
> CBLQuery *query = [view createQuery];
>
> query.descending = YES;
>
> query.startKey = @[docID, @{}]; // ...this crashes
>
> query.endKey = @[docID];
>
> return query;
>
> }
>
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/76b9d955-b573-4fc6-9c78-34fdba223757%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.