Skip to content

Commit bab7f63

Browse files
committed
updated decimal to 1.8
1 parent ca0cd7e commit bab7f63

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* refactored usage of `ReadPreference`
77
* added support for sessions (`ServerSession`, `SessionPool`, `Session`)
88
* added support for transaction
9+
* added Decimal128 encoder
910

1011
## 0.5.7
1112

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ for the individual options.
2222
* [x] Removed depreacated op codes ([See](https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#request-opcodes))
2323
* [x] Added `op_msg` support ([See](https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#op-msg))
2424
* [x] Added bulk writes ([See](https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#write))
25-
* [ ] Add support for driver sessions ([See](https://github.com/mongodb/specifications/blob/master/source/sessions/driver-sessions.rst))
26-
* [ ] Add support driver transactions ([See](https://github.com/mongodb/specifications/blob/master/source/transactions/transactions.rst))
25+
* [x] Add support for driver sessions ([See](https://github.com/mongodb/specifications/blob/master/source/sessions/driver-sessions.rst))
26+
* [x] Add support driver transactions ([See](https://github.com/mongodb/specifications/blob/master/source/transactions/transactions.rst))
2727
* [ ] Add support for `op_compressed` ([See](https://github.com/mongodb/specifications/blob/master/source/compression/OP_COMPRESSED.rst))
2828
* [ ] Because the driver is used in production environments, quick adjustments are necessary.
2929

3030
## Features
3131

32-
* Supports MongoDB versions 3.2, 3.4, 3.6, 4.0
32+
* Supports MongoDB versions 3.2, 3.4, 3.6, 4.0, 4.2
3333
* Connection pooling ([through DBConnection 2.x](https://github.com/elixir-ecto/db_connection))
3434
* Streaming cursors
3535
* Performant ObjectID generation
@@ -57,6 +57,7 @@ for the individual options.
5757
symbol "foo" (2)
5858
min key :BSON_min
5959
max key :BSON_max
60+
decimal128 Decimal{}
6061

6162
1) Since BSON documents are ordered Elixir maps cannot be used to fully represent them. This driver chose to accept both maps and lists of key-value pairs when encoding but will only decode documents to lists. This has the side-effect that it's impossible to discern empty arrays from empty documents. Additionally the driver will accept both atoms and strings for document keys but will only decode to strings.
6263

lib/bson/decimal128.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ defmodule BSON.Decimal128 do
4242
<<low::little-64, high::little-64>>
4343
end
4444

45-
def encode(%Decimal{sign: sign, coef: significand, exp: exponent}) do
46-
message = "Exponent is out of range for Decimal128 encoding"
45+
def encode(%Decimal{exp: exponent}) do
46+
message = "Exponent is out of range for Decimal128 encoding, #{exponent}"
4747
raise ArgumentError, message
4848
end
4949

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ defmodule Mongodb.Mixfile do
3838
[
3939
{:connection, "~> 1.0"},
4040
{:db_connection, "~> 2.0.6"},
41-
{:decimal, "~> 1.5"},
41+
{:decimal, "~> 1.8"},
4242
{:benchee, "~> 1.0", only: :dev},
4343
{:jason, "~> 1.0.0", only: :test},
4444
{:ex_doc, "~> 0.20.1 ", only: :dev},

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"benchee": {:hex, :benchee, "1.0.1", "66b211f9bfd84bd97e6d1beaddf8fc2312aaabe192f776e8931cb0c16f53a521", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm"},
33
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"},
44
"db_connection": {:hex, :db_connection, "2.0.6", "bde2f85d047969c5b5800cb8f4b3ed6316c8cb11487afedac4aa5f93fd39abfa", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"},
5-
"decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [:mix], [], "hexpm"},
5+
"decimal": {:hex, :decimal, "1.8.0", "ca462e0d885f09a1c5a342dbd7c1dcf27ea63548c65a65e67334f4b61803822e", [:mix], [], "hexpm"},
66
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm"},
77
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
88
"earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm"},

test/mongo_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,8 @@ defmodule Mongo.Test do
556556
@tag :mongo_3_4
557557
test "correctly query NumberDecimal", c do
558558
coll = "number_decimal_test"
559-
Mongo.insert_one(c.pid, coll, %{number: Decimal.new(123.456), index: 1})
560-
Mongo.insert_one(c.pid, coll, %{number: Decimal.new(-123.456), index: 2})
559+
Mongo.insert_one(c.pid, coll, %{number: Decimal.from_float(123.456), index: 1})
560+
Mongo.insert_one(c.pid, coll, %{number: Decimal.from_float(-123.456), index: 2})
561561
assert %{"number" => %Decimal{coef: 123456, exp: -3}} = Mongo.find(c.pid, coll, %{index: 1}, limit: 1) |> Enum.to_list |> List.first()
562562
assert %{"number" => %Decimal{sign: -1, coef: 123456, exp: -3}} = Mongo.find(c.pid, coll, %{index: 2}, limit: 1) |> Enum.to_list |> List.first()
563563
end

0 commit comments

Comments
 (0)