Closed Tuxified closed 5 months ago
Hey Tuxified,
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.
Thank you for reporting this issue!
Alright, finally got around making a small PR, plz let me know if you have questions/comments
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: