This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull fixes an edge case with querying a view before the view's design document is fetched via replication. Here's what my app is doing:
_design/books
.ddoc = [CouchDatabase designDocumentWithName:@"books"]
. The ddoc doesn't exist locally yet, so it is created.[ddoc mapFunctionOfViewNamed:@"by_author"]
returns null, but this populates the_views
cache in CouchDesignDocument._viewsRevisionID
andself.currentRevisionID
are equal and null, so the view cache is not cleared.mapFunctionOfViewNamed
continue to return null even though there is a map function.If I restart the app at this point, the map function is returned from CouchDesignDocument as expected. I wasn't able to figure out why the currentRevisionID of the design document wasn't updated during the replication process. My workaround was to not cache the views for a design document unless that document has a non-null
_viewRevisionID
.This probably hasn't come up before because most people aren't using map and filter functions stored in a design document due to the restriction on downloadable code in an iOS app. My code provides a JavaScript view compiler, so it is important to me to be able to replicate ddoc view functions. Let me know what you think or if you have any alternative suggestions for a workaround. Thanks!