Skip to content

Commit fdeb69e

Browse files
committed
Allow use of and with fragments
Add test for and with fragment Use List.wrap/1 instead of flattening
1 parent 62f7471 commit fdeb69e

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/mongo_ecto/normalized_query.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ defmodule Mongo.Ecto.NormalizedQuery do
367367
end)
368368

369369
defp mapped_pair_or_value({op, _, _} = tuple, params, pk, query, place) when is_op(op) do
370-
[pair(tuple, params, pk, query, place)]
370+
List.wrap(pair(tuple, params, pk, query, place))
371371
end
372372
defp mapped_pair_or_value(value, params, pk, query, place) do
373373
value(value, params, pk, query, place)

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"ecto": {:hex, :ecto, "2.1.6", "29b45f393c2ecd99f83e418ea9b0a2af6078ecb30f401481abac8a473c490f84", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, optional: true]}]},
77
"ex_doc": {:hex, :ex_doc, "0.16.2", "3b3e210ebcd85a7c76b4e73f85c5640c011d2a0b2f06dcdf5acdb2ae904e5084", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]},
88
"inch_ex": {:hex, :inch_ex, "0.5.6", "418357418a553baa6d04eccd1b44171936817db61f4c0840112b420b8e378e67", [:mix], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, optional: false]}]},
9-
"mongodb": {:git, "https://github.com/ankhers/mongodb.git", "d2d0954da6385a525d8d3577d28c19fb0b215349", [branch: "reboot_replica_sets"]},
9+
"mongodb": {:git, "https://github.com/ankhers/mongodb.git", "27767600c4049c7d15fc8185d25bb7678854bfb7", [branch: "reboot_replica_sets"]},
1010
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []},
1111
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []}}

test/mongo_ecto_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ defmodule Mongo.EctoTest do
2626
p2 = TestRepo.insert!(%Post{title: "other text"})
2727

2828
assert [p1] == TestRepo.all(from p in Post, where: fragment(title: ["$regex": "some"]))
29-
assert [p2] == TestRepo.all(from p in Post, where: fragment(title: ^regex("other")))
29+
assert [p2] == TestRepo.all(from p in Post, where: fragment(title: ^regex("other")) and fragment(title: ^regex("text")))
3030
end
3131

3232
test "retrieve whole document" do

0 commit comments

Comments
 (0)