Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #39 from Zephyrean/master

Fix for exception caused by float specials and support for 2 more operators
  • Loading branch information...
commit 635a3657cc6c42babc10c5f3116afe726054300a 2 parents b91bba0 + 23cd1a8
@SergejJurecko authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 src/mongodb.erl
View
13 src/mongodb.erl
@@ -1214,6 +1214,8 @@ encode_element({Name, {set, Val}}) ->
encode_element({<<"$set">>, [{Name, Val}]});
encode_element({Name, {unset, Val}}) ->
encode_element({<<"$unset">>, [{Name, Val}]});
+encode_element({Name, {push, [{each, Arr}, {slice, Num}]}}) ->
+ encode_element({<<"$push">>,[{Name, [{<<"$each">>,{array, Arr}},{<<"$slice">>,Num}]}]});
encode_element({Name, {push, Val}}) ->
encode_element({<<"$push">>, [{Name, Val}]});
encode_element({Name, {pushAll, Val}}) ->
@@ -1228,6 +1230,8 @@ encode_element({Name, {addToSet, {array,Val}}}) ->
encode_element({<<"$addToSet">>, [{Name, [{<<"$each">>, {array, Val}}]}]});
encode_element({Name, {addToSet, Val}}) ->
encode_element({<<"$addToSet">>, [{Name, Val}]});
+encode_element({Name, {near, Val}}) ->
+ encode_element({Name, [{<<"$near">>, {array, Val}}]});
encode_element({Name, {gt, Val}}) ->
encode_element({Name, [{<<"$gt">>, Val}]});
encode_element({Name, {lt, Val}}) ->
@@ -1355,8 +1359,13 @@ decode_value(16, <<Integer:32/little-signed, Rest/binary>>) ->
{Integer, Rest};
decode_value(18, <<Integer:64/little-signed, Rest/binary>>) ->
{Integer, Rest};
-decode_value(1, <<Double:64/little-signed-float, Rest/binary>>) ->
- {Double, Rest};
+decode_value(1, <<DoubleBin:8/binary, Rest/binary>>) ->
+ try
+ <<Double:64/little-signed-float>> = DoubleBin,
+ {Double, Rest}
+ catch error:{badmatch, _Bin} ->
+ {0, Rest}
+ end;
decode_value(2, <<Size:32/little-signed, Rest/binary>>) ->
StringSize = Size-1,
case Rest of
Please sign in to comment.
Something went wrong with that request. Please try again.