Skip to content

bug when 'avgDistance' value is NaN#17

Open
dbdn wants to merge 1 commit intocomtihon:masterfrom
dbdn:master
Open

bug when 'avgDistance' value is NaN#17
dbdn wants to merge 1 commit intocomtihon:masterfrom
dbdn:master

Conversation

@dbdn
Copy link

@dbdn dbdn commented Sep 7, 2016

when use mongodb-erlang to execute mongodb command geoNear , but when no fields selected it will return

{
        "results" : [ ],
        "stats" : {
                "nscanned" : 0,
                "objectsLoaded" : 0,
                "avgDistance" : NaN,
                "maxDistance" : 0,
                "time" : 0
        },
        "ok" : 1
}

in this case "avgDistance" : NaN. its not a float type, so will cause the below code badmatch error.

get_field(<<1:8, _/binary>>, _, Bin1, _) ->
  <<?get_float(N), Bin2/binary>> = Bin1,
  {N, Bin2};

error details is:

18:25:25.966 [error] gen_server <0.127.0> terminated with reason: no match of right hand value <<0,0,0,0,0,0,248,255,1,109,97,120,68,105,115,116,97,110,99,101,0,0,0,0,0,0,0,0,0,16,116,105,109,101,0,0,0,0,0>> in bson_binary:get_field/4 line 87
18:25:26.072 [error] CRASH REPORT Process <0.127.0> with 1 neighbours exited with reason: no match of right hand value <<0,0,0,0,0,0,248,255,1,109,97,120,68,105,115,116,97,110,99,101,0,0,0,0,0,0,0,0,0,16,116,105,109,101,0,0,0,0,0>> in bson_binary:get_field/4 line 87 in gen_server:terminate/7 line 826
** exception exit: {badmatch,<<0,0,0,0,0,0,248,255,1,109,97,120,68,105,115,
                               116,97,110,99,101,0,0,0,0,0,0,0,...>>}
     in function  bson_binary:get_field/4 (src/bson_binary.erl, line 87)
     in call from bson_binary:get_field/2 (src/bson_binary.erl, line 151)
     in call from bson_binary:get_fields/2 (src/bson_binary.erl, line 54)
     in call from bson_binary:get_map/1 (src/bson_binary.erl, line 40)
     in call from bson_binary:get_field/2 (src/bson_binary.erl, line 151)
     in call from bson_binary:get_fields/2 (src/bson_binary.erl, line 54)
     in call from bson_binary:get_map/1 (src/bson_binary.erl, line 40)
     in call from mongo_protocol:get_docs/3 (src/core/mongo_protocol.erl, line 115)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant