You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I stumbled upon a bug: if someone supplies wrong arguments to Mongo.update/4, it results in an endless recursive call to normalise_updates/1 (a private function). The update/4 has 4 params: topology_pid, collection, updates, opts . updates should be a list of keyword lists, but if it's anything else is supplied (e.g empty list) it seems to goes south.
defupdate(topology_pid,coll,updates,opts)dowrite_concern=filter_nils(%{w: Keyword.get(opts,:w),j: Keyword.get(opts,:j),wtimeout: Keyword.get(opts,:wtimeout)})normalised_updates=updates|>normalise_updates()# rest of update functiondefpnormalise_updates([[{_,_}|_]|_]=updates)doupdates|>Enum.map(&normalise_update/1)enddefpnormalise_updates(updates),do: normalise_updates([updates])
If you agree this is a bug, I'm willing to submit a patch.
I'm a bit new to Mongo, so not sure what the expected behaviour is, but I propose to change it such that update/4 checks if updates is a keyword list with at least q/query + u/update/update keys, WDYT?
yes, it make sense to capture the empty list and maybe raise an exception or return an error in this case. To be honestly I never used the function. It was introduced to support the ecto MongoDB framework. Please feel free to submit a PR.
Hi,
I think I stumbled upon a bug: if someone supplies wrong arguments to Mongo.update/4, it results in an endless recursive call to normalise_updates/1 (a private function). The update/4 has 4 params: topology_pid, collection, updates, opts .
updates
should be a list of keyword lists, but if it's anything else is supplied (e.g empty list) it seems to goes south.This is the snippet which I think are relevant (from https://github.com/zookzook/elixir-mongodb-driver/blob/master/lib/mongo.ex#L1133 ):
If you agree this is a bug, I'm willing to submit a patch.
I'm a bit new to Mongo, so not sure what the expected behaviour is, but I propose to change it such that update/4 checks if
updates
is a keyword list with at least q/query + u/update/update keys, WDYT?Small snippet to reproduce:
The text was updated successfully, but these errors were encountered: