checkiz / elixir-mongo

MongoDB driver for Elixir
MIT License
101 stars 31 forks source link

Fix auth to send db's name to Mongo.Request.cmd #32

Closed localshred closed 8 years ago

localshred commented 8 years ago

When attempting to use the Mongo.Db.auth/3 command I ran into an issue where the underying Mongo.Request.cmd was expecting the first argument to be the name of the database as a string, but was instead receiving the entire %Mongo.Db{} struct.

The relevant parts of my stacktrace:

** (exit) an exception was raised:
    ** (ArgumentError) argument error
        :erlang.byte_size(%Mongo.Db{auth: {"myuser", "4f75033e39d8b884aa7d88e2fadfe2cb"}, mongo: %Mongo.Server{host: 'localhost', id_prefix: 8457, mode: :passive, opts: %{}, port: 27017, socket: #Port<0.6963>, timeout: 6000}, name: "gretel_dev", opts: %{mode: :passive, timeout: 6000}})
        lib/mongo_request.ex:41: Mongo.Request.cmd/3
        lib/mongo_db.ex:44: Mongo.Db.auth/1

The fix is simple enough, though I didn't see any tests that would need to be modified. Let me know if I missed any of that.

localshred commented 8 years ago

Oh, and thanks for the awesome package!

localshred commented 8 years ago

After running this code I'm now getting an error that Mongo.Server doesn't respond to call/1. I'm bisecting back through the server's history and never see it as a GenServer. Any info you can provide?