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.
Overview
This PR implements "phase 1" of the functionality outlined in #5792, i.e. it adds the ability for
validate_doc_updateto be implemented as a Mango selector expression, rather than as a JavaScript function. The selector is evaluated against an ephemeral JSON structure containingnewDoc(the new doc version to be saved) andoldDoc(the one currently on disk). For example, saving the following to/db/_design/mango-vduwill cause all docs to be checked for atypefield which must be a string:{ "language": "query", "validate_doc_update": { "newDoc": { "type": { "$type": "string" } } } }This uses the existing infrastructure of
couch_query_serversandmango_native_proc, just adding appropriate message handlers to Mango processes for handling VDU requests.Testing recommendations
The added tests cover the basic functionality to check that Mango validators can be saved, and the in-memory cache is updated as appropriate. It assumes Mango works as it does in current releases and so does not re-test all the Mango functionality in detail.
Since there are now two different languages VDUs can be written in, I may have missed anything that assumes there's only one way to do it. I did however notice a counter being updated incorrectly, which is now fixed.
Related Issues or Pull Requests
Checklist
rel/overlay/etc/default.inisrc/docsfolder