-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Mango match_failures/2 function
#5858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2b2345d
35f7bef
0ee3ae7
7aaeca4
1d54f34
522ff2f
46ea2c5
3154d67
3bc88cd
4454e60
4f89067
0788d06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -248,12 +248,11 @@ validate(Db, DDoc) -> | |
| ok | ||
| end, | ||
|
|
||
| try Views =/= [] andalso couch_query_servers:get_os_process(Lang) of | ||
| false -> | ||
| ok; | ||
| try couch_query_servers:get_os_process(Lang) of | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One change here to watch out for is that previously if ddoc didn't have views we didn't check out an OS process. Now we always do. Could we first check if we have views or a VDU and only then go into
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I'll move these checks around so we avoid grabbing an OS process if it's not needed. |
||
| Proc -> | ||
| try | ||
| lists:foreach(fun(V) -> ValidateView(Proc, V) end, Views) | ||
| lists:foreach(fun(V) -> ValidateView(Proc, V) end, Views), | ||
| validate_vdu(Proc, DDoc) | ||
| after | ||
| couch_query_servers:ret_os_process(Proc) | ||
| end | ||
|
|
@@ -263,6 +262,21 @@ validate(Db, DDoc) -> | |
| ok | ||
| end. | ||
|
|
||
| validate_vdu(Proc, #doc{body = {Props}}) -> | ||
| case config:get_boolean("couchdb", "validate_vdu", false) of | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the |
||
| true -> | ||
| case couch_util:get_value(<<"validate_doc_update">>, Props) of | ||
| undefined -> | ||
| ok; | ||
| VDU -> | ||
| couch_query_servers:try_compile( | ||
| Proc, validate_doc_update, <<"validate_doc_update">>, VDU | ||
| ) | ||
| end; | ||
| _ -> | ||
| ok | ||
| end. | ||
|
|
||
| check_rank(<<N/binary>>) -> | ||
| try binary_to_integer(N) of | ||
| Val when Val >= 1 andalso Val =< ?MAX_RANK -> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if query language is Erlang? Do we get an immediate 500 or some nicer invalid language 400 response?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only validate the function if
languageisjavascriptorquery;couch_mrview:validate()explicitly ends by accepting anything that's not recognised, i.e. you can save any design doc you like if it contains content CouchDB does not natively understand. This is very convenient for enabling other software to integrate with CouchDB.We could add validation for
erlangfunctions but that feels like expanding the scope of this PR into things that aren't strictly related and I'm not sure how to implement.