comtihon / mongodb-erlang

MongoDB driver for Erlang
Apache License 2.0
342 stars 267 forks source link

Support for mongo's `Infinity` #84

Open lafka opened 9 years ago

lafka commented 9 years ago

Loading documents that contains Infinity fails due to BSON parsers can't decode the float:

// insert in mongo shell
db.test.insert({"hello": Infinity})
# try to query back
:poolboy.transaction :mongodb, fn(conn) -> :mongo.find_one(conn, :test, %{}) end
** (exit) exited in: :gen_server.call(#PID<0.3001.0>, {:query, false, false, false, false, :test, 0, -1, %{}, []}, :infinity)
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: <<0, 0, 0, 0, 0, 0, 240, 127>>
            (bson) src/bson_binary.erl:87: :bson_binary.get_field/4
            (bson) src/bson_binary.erl:144: :bson_binary.get_field/2
            (bson) src/bson_binary.erl:54: :bson_binary.get_fields/2
            (bson) src/bson_binary.erl:40: :bson_binary.get_map/1
            (mongodb) src/core/mongo_protocol.erl:111: :mongo_protocol.get_docs/3
            (mongodb) src/core/mongo_protocol.erl:92: :mongo_protocol.get_reply/1
            (mongodb) src/connection/mc_worker_logic.erl:68: :mc_worker_logic.decode_responses/2
            (mongodb) src/connection/mc_worker.erl:102: :mc_worker.handle_info/2

There is a pull request for it in the bson-erlang repo put i'm posting it here for reference.

comtihon commented 9 years ago

Yes, I got it.