-
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
b58e717
09b3ed5
412bb3e
d05fbe2
16bb9f1
0eab7ad
d467e70
1d4dbb0
ba11d38
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 |
|---|---|---|
|
|
@@ -112,14 +112,30 @@ handle_call({prompt, [<<"ddoc">>, DDocId, [<<"validate_doc_update">>], Args]}, _ | |
| Msg = [<<"validate_doc_update">>, DDocId], | ||
| {stop, {invalid_call, Msg}, {invalid_call, Msg}, St}; | ||
| Selector -> | ||
| [NewDoc, OldDoc, _Ctx, _SecObj] = Args, | ||
| Struct = {[{<<"newDoc">>, NewDoc}, {<<"oldDoc">>, OldDoc}]}, | ||
| Reply = | ||
| case mango_selector:match(Selector, Struct) of | ||
| true -> true; | ||
| _ -> {[{<<"forbidden">>, <<"document is not valid">>}]} | ||
| end, | ||
| {reply, Reply, St} | ||
| case mango_selector:has_allowed_fields(Selector, [<<"newDoc">>, <<"oldDoc">>]) of | ||
| false -> | ||
| Msg = | ||
| <<"'validate_doc_update' may only contain 'newDoc' and 'oldDoc' as top-level fields">>, | ||
|
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. I wonder when this would fire, would it be on every time we attempt to insert a doc we'd crash the prompt? |
||
| {stop, {invalid_call, Msg}, {invalid_call, Msg}, St}; | ||
| true -> | ||
| [NewDoc, OldDoc, _Ctx, _SecObj] = Args, | ||
| Struct = | ||
| case OldDoc of | ||
| null -> {[{<<"newDoc">>, NewDoc}]}; | ||
|
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. Does this mean before we allowed OldDoc = null and now we skip it when it's null? I guess we haven't made a release so it won't break anything. |
||
| Doc -> {[{<<"newDoc">>, NewDoc}, {<<"oldDoc">>, Doc}]} | ||
| end, | ||
| Reply = | ||
| case mango_selector:match_failures(Selector, Struct) of | ||
| [] -> | ||
| true; | ||
| Failures -> | ||
| {[ | ||
| {<<"forbidden">>, <<"forbidden">>}, | ||
|
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 would change the message to |
||
| {<<"failures">>, Failures} | ||
| ]} | ||
| end, | ||
| {reply, Reply, St} | ||
| end | ||
| end; | ||
| handle_call(Msg, _From, St) -> | ||
| {stop, {invalid_call, Msg}, {invalid_call, Msg}, St}. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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're changing the forbidden tuple shape. Make sure to check all the places which handle
{forbidden, _}and now they may have to handle the triple-arg version. I noticed fabric_doc_update needs to handle this src/fabric/src/fabric_doc_update.erlWe should also call out and see if this will affect online cluster upgrades (new worker nodes throwing it and old coordinator nodes getting function clause errors). It maybe be fine, just needs an extra careful look at it.