Skip to content

Commit 0b61b46

Browse files
authored
Merge pull request #6 from auser/ecto-2
Ecto 2
2 parents 6d557cf + ebd1468 commit 0b61b46

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/mongo_ecto/conversions.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ defmodule Mongo.Ecto.Conversions do
2424
do: document(doc, params, pk)
2525
def inject_params(list, params, pk) when is_list(list),
2626
do: map(list, &inject_params(&1, params, pk))
27+
def inject_params(%Ecto.Query.Tagged{tag: tag, type: type, value: {:^, _, [idx]} = value}, params, pk) do
28+
## If we need to cast the values of the return, they should go here
29+
elem(params, idx) |> inject_params(params, pk)
30+
end
2731
def inject_params({:^, _, [idx]}, params, pk),
2832
do: elem(params, idx) |> inject_params(params, pk)
2933
def inject_params(%{__struct__: _} = struct, _params, pk),
@@ -40,6 +44,9 @@ defmodule Mongo.Ecto.Conversions do
4044
:error -> :error
4145
end
4246
end
47+
48+
def from_ecto_pk(%Ecto.Query.Tagged{tag: :binary_id, value: value}, _pk),
49+
do: {:ok, BSON.Decoder.decode(value)}
4350
def from_ecto_pk(%Ecto.Query.Tagged{type: type, value: value}, _pk),
4451
do: Ecto.Type.adapter_dump(Mongo.Ecto, type, value)
4552
def from_ecto_pk(%Mongo.Ecto.Regex{} = regex, _pk),

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"decimal": {:hex, :decimal, "1.3.1", "157b3cedb2bfcb5359372a7766dd7a41091ad34578296e951f58a946fcab49c6", [:mix], []},
55
"dialyze": {:hex, :dialyze, "0.2.1", "9fb71767f96649020d769db7cbd7290059daff23707d6e851e206b1fdfa92f9d", [:mix], []},
66
"earmark": {:hex, :earmark, "0.2.1", "ba6d26ceb16106d069b289df66751734802777a3cbb6787026dd800ffeb850f3", [:mix], []},
7-
"ecto": {:hex, :ecto, "2.0.5", "7f4c79ac41ffba1a4c032b69d7045489f0069c256de606523c65d9f8188e502d", [:mix], [{:db_connection, "~> 1.0-rc.4", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.1.2 or ~> 1.2", [hex: :decimal, optional: false]}, {:mariaex, "~> 0.7.7", [hex: :mariaex, optional: true]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}, {:postgrex, "~> 0.12.0", [hex: :postgrex, optional: true]}, {:sbroker, "~> 1.0-beta", [hex: :sbroker, optional: true]}]},
7+
"ecto": {:hex, :ecto, "2.0.6", "9dcbf819c2a77f67a66b83739b7fcc00b71aaf6c100016db4f798930fa4cfd47", [:mix], [{:db_connection, "~> 1.0", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.1.2 or ~> 1.2", [hex: :decimal, optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, optional: true]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}, {:postgrex, "~> 0.12.0", [hex: :postgrex, optional: true]}, {:sbroker, "~> 1.0-beta", [hex: :sbroker, optional: true]}]},
88
"ex_doc": {:hex, :ex_doc, "0.12.0", "b774aabfede4af31c0301aece12371cbd25995a21bb3d71d66f5c2fe074c603f", [:mix], [{:earmark, "~> 0.2", [hex: :earmark, optional: false]}]},
99
"excoveralls": {:hex, :excoveralls, "0.5.7", "5d26e4a7cdf08294217594a1b0643636accc2ad30e984d62f1d166f70629ff50", [:mix], [{:exjsx, "~> 3.0", [hex: :exjsx, optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, optional: false]}]},
1010
"exjsx": {:hex, :exjsx, "3.2.1", "1bc5bf1e4fd249104178f0885030bcd75a4526f4d2a1e976f4b428d347614f0f", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, optional: false]}]},

0 commit comments

Comments
 (0)