Permalink
Browse files

Ignore identity when its not available.

For example, when you're looking at the results 
of a reduce function.
  • Loading branch information...
1 parent 758fb43 commit 028e2e0257e44ade1a3137614b108988f00df4d2 @objectiveous committed Apr 14, 2009
Showing with 4 additions and 2 deletions.
  1. +4 −2 Classes/SBCouchEnumerator.m
@@ -250,7 +250,8 @@ -(void)appendCouchDocuments:(NSArray*)listOfDictionaries{
// and it would be a mistake to assume that anytime we have an 'id' key in the dict that it is an actual identity.
// For example, someone could create a view that returns the keys: _id, id, and key. Then what would we do?
// CouchDB may move _id into the HTTP headers, so we won't get to worried just yet.
- [(SBCouchDocument*)doc setIdentity:documentType];
+ if(documentType != nil)
+ [(SBCouchDocument*)doc setIdentity:documentType];
}
[self.rows addObject:doc];
}
@@ -290,7 +291,7 @@ -(BOOL)hasNextBatch{
//if([self.rows count] >= self.totalRows && ! self.currentIndex < [self.rows count])
// return NO;
- if(self.totalRows >= self.queryOptions.limit && self.queryOptions.limit >= self.sizeOfLastFetch && self.totalRows != [self.rows count])
+ if(self.totalRows > self.queryOptions.limit && self.queryOptions.limit >= self.sizeOfLastFetch && self.totalRows != [self.rows count])
return YES;
if(self.currentIndex + self.queryOptions.limit + 1 < self.totalRows)
@@ -350,6 +351,7 @@ -(void)resetLimit:(NSInteger)limit{
self.queryOptions.skip = 0;
self.currentIndex = -1;
self.metadataLoaded = NO;
+ //self.totalRows = -1;
[self.rows removeAllObjects];
//self.rows = [NSMutableArray arrayWithCapacity:limit];
[self count];

0 comments on commit 028e2e0

Please sign in to comment.