summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabor Pali <gabor.pali@ibm.com>2023-04-17 22:33:47 +0200
committerNick Vatamaniuc <nickva@users.noreply.github.com>2023-04-18 23:51:32 -0400
commit1ed0519a15427b0db6d03ecdc543227691fc3bbc (patch)
tree310acf6a8337b015324a43e96cf2d46100c35435
parentc5a7809f06fb20c6d52d8fedf07ef0b4219c0de7 (diff)
downloadcouchdb-1ed0519a15427b0db6d03ecdc543227691fc3bbc.tar.gz
Remove explicit import
-rw-r--r--src/mango/src/mango_idx_text.erl133
-rw-r--r--src/mango/src/mango_selector_text.erl130
2 files changed, 120 insertions, 143 deletions
diff --git a/src/mango/src/mango_idx_text.erl b/src/mango/src/mango_idx_text.erl
index db8af795b..21b818288 100644
--- a/src/mango/src/mango_idx_text.erl
+++ b/src/mango/src/mango_idx_text.erl
@@ -29,10 +29,6 @@
-include("mango.hrl").
-include("mango_idx.hrl").
--ifdef(TEST).
--import(test_util, [as_selector/1]).
--endif.
-
validate_new(#idx{} = Idx, Db) ->
{ok, Def} = do_validate(Idx#idx.def),
maybe_reject_index_all_req(Def, Db),
@@ -476,76 +472,73 @@ warn_index_all({Idx, Db}) ->
?assertThrow({test_error, logged_warning}, validate_new(Idx, Db))
end).
+indexable(Selector) ->
+ indexable_fields(test_util:as_selector(Selector)).
+
indexable_fields_test() ->
?assertEqual(
[<<"$default">>, <<"field1:boolean">>, <<"field2:number">>, <<"field3:string">>],
- indexable_fields(
- as_selector(
- #{
- <<"$default">> => #{<<"$text">> => <<"text">>},
- <<"field1">> => true,
- <<"field2">> => 42,
- <<"field3">> => #{<<"$regex">> => <<".*">>}
- }
- )
+ indexable(
+ #{
+ <<"$default">> => #{<<"$text">> => <<"text">>},
+ <<"field1">> => true,
+ <<"field2">> => 42,
+ <<"field3">> => #{<<"$regex">> => <<".*">>}
+ }
)
),
?assertEqual(
[<<"f1:string">>, <<"f2:string">>, <<"f3:string">>, <<"f4:string">>, <<"f5:string">>],
lists:sort(
- indexable_fields(
- as_selector(
- #{
- <<"$and">> =>
- [
- #{<<"f1">> => <<"v1">>},
- #{<<"f2">> => <<"v2">>}
- ],
- <<"$or">> =>
- [
- #{<<"f3">> => <<"v3">>},
- #{<<"f4">> => <<"v4">>}
- ],
- <<"$not">> => #{<<"f5">> => <<"v5">>}
- }
- )
- )
- )
- ),
-
- ?assertEqual(
- [],
- indexable_fields(
- as_selector(
- #{
- <<"field1">> => null,
- <<"field2">> => #{<<"$size">> => 3},
- <<"field3">> => #{<<"$type">> => <<"type">>}
- }
- )
- )
- ),
- ?assertEqual(
- [],
- indexable_fields(
- as_selector(
+ indexable(
#{
<<"$and">> =>
[
- #{<<"f1">> => null},
- #{<<"f2">> => null}
+ #{<<"f1">> => <<"v1">>},
+ #{<<"f2">> => <<"v2">>}
],
<<"$or">> =>
[
- #{<<"f3">> => null},
- #{<<"f4">> => null}
+ #{<<"f3">> => <<"v3">>},
+ #{<<"f4">> => <<"v4">>}
],
- <<"$not">> => #{<<"f5">> => null}
+ <<"$not">> => #{<<"f5">> => <<"v5">>}
}
)
)
+ ),
+ ?assertEqual(
+ [],
+ indexable(
+ #{
+ <<"field1">> => null,
+ <<"field2">> => #{<<"$size">> => 3},
+ <<"field3">> => #{<<"$type">> => <<"type">>}
+ }
+ )
+ ),
+ ?assertEqual(
+ [],
+ indexable(
+ #{
+ <<"$and">> =>
+ [
+ #{<<"f1">> => null},
+ #{<<"f2">> => null}
+ ],
+ <<"$or">> =>
+ [
+ #{<<"f3">> => null},
+ #{<<"f4">> => null}
+ ],
+ <<"$not">> => #{<<"f5">> => null}
+ }
+ )
).
+usable(Index, Selector, Fields) ->
+ is_usable(Index, test_util:as_selector(Selector), Fields).
+
is_usable_test() ->
?assertNot(is_usable(undefined, {[]}, undefined)),
@@ -555,38 +548,38 @@ is_usable_test() ->
Field1 = {[{<<"name">>, <<"field1">>}, {<<"type">>, <<"string">>}]},
Field2 = {[{<<"name">>, <<"field2">>}, {<<"type">>, <<"number">>}]},
Index = #idx{def = {[{<<"fields">>, [Field1, Field2]}]}},
- ?assert(is_usable(Index, as_selector(#{<<"field1">> => <<"value">>}), undefined)),
- ?assertNot(is_usable(Index, as_selector(#{<<"field1">> => 42}), undefined)),
- ?assertNot(is_usable(Index, as_selector(#{<<"field3">> => true}), undefined)),
+ ?assert(usable(Index, #{<<"field1">> => <<"value">>}, undefined)),
+ ?assertNot(usable(Index, #{<<"field1">> => 42}, undefined)),
+ ?assertNot(usable(Index, #{<<"field3">> => true}, undefined)),
?assert(
- is_usable(Index, as_selector(#{<<"field1">> => #{<<"$type">> => <<"string">>}}), undefined)
+ usable(Index, #{<<"field1">> => #{<<"$type">> => <<"string">>}}, undefined)
),
?assert(
- is_usable(Index, as_selector(#{<<"field1">> => #{<<"$type">> => <<"boolean">>}}), undefined)
+ usable(Index, #{<<"field1">> => #{<<"$type">> => <<"boolean">>}}, undefined)
),
?assert(
- is_usable(Index, as_selector(#{<<"field3">> => #{<<"$type">> => <<"boolean">>}}), undefined)
+ usable(Index, #{<<"field3">> => #{<<"$type">> => <<"boolean">>}}, undefined)
),
- ?assert(is_usable(Index, as_selector(#{<<"field1">> => #{<<"$exists">> => true}}), undefined)),
- ?assert(is_usable(Index, as_selector(#{<<"field1">> => #{<<"$exists">> => false}}), undefined)),
- ?assert(is_usable(Index, as_selector(#{<<"field3">> => #{<<"$exists">> => true}}), undefined)),
- ?assert(is_usable(Index, as_selector(#{<<"field3">> => #{<<"$exists">> => false}}), undefined)),
+ ?assert(usable(Index, #{<<"field1">> => #{<<"$exists">> => true}}, undefined)),
+ ?assert(usable(Index, #{<<"field1">> => #{<<"$exists">> => false}}, undefined)),
+ ?assert(usable(Index, #{<<"field3">> => #{<<"$exists">> => true}}, undefined)),
+ ?assert(usable(Index, #{<<"field3">> => #{<<"$exists">> => false}}, undefined)),
?assert(
- is_usable(Index, as_selector(#{<<"field1">> => #{<<"$regex">> => <<".*">>}}), undefined)
+ usable(Index, #{<<"field1">> => #{<<"$regex">> => <<".*">>}}, undefined)
),
?assertNot(
- is_usable(Index, as_selector(#{<<"field2">> => #{<<"$regex">> => <<".*">>}}), undefined)
+ usable(Index, #{<<"field2">> => #{<<"$regex">> => <<".*">>}}, undefined)
),
?assertNot(
- is_usable(Index, as_selector(#{<<"field3">> => #{<<"$regex">> => <<".*">>}}), undefined)
+ usable(Index, #{<<"field3">> => #{<<"$regex">> => <<".*">>}}, undefined)
),
?assertNot(
- is_usable(Index, as_selector(#{<<"field1">> => #{<<"$nin">> => [1, 2, 3]}}), undefined)
+ usable(Index, #{<<"field1">> => #{<<"$nin">> => [1, 2, 3]}}, undefined)
),
?assert(
- is_usable(Index, as_selector(#{<<"field2">> => #{<<"$nin">> => [1, 2, 3]}}), undefined)
+ usable(Index, #{<<"field2">> => #{<<"$nin">> => [1, 2, 3]}}, undefined)
),
?assertNot(
- is_usable(Index, as_selector(#{<<"field3">> => #{<<"$nin">> => [1, 2, 3]}}), undefined)
+ usable(Index, #{<<"field3">> => #{<<"$nin">> => [1, 2, 3]}}, undefined)
).
-endif.
diff --git a/src/mango/src/mango_selector_text.erl b/src/mango/src/mango_selector_text.erl
index 0d18516c9..1f8609ac2 100644
--- a/src/mango/src/mango_selector_text.erl
+++ b/src/mango/src/mango_selector_text.erl
@@ -21,10 +21,6 @@
-include("mango.hrl").
--ifdef(TEST).
--import(test_util, [as_selector/1]).
--endif.
-
%% Regex for <<"\\.">>
-define(PERIOD, "\\.").
@@ -441,22 +437,25 @@ replace_array_indexes([Part | Rest], NewPartsAcc, HasIntAcc) ->
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
+convert_selector(Selector) ->
+ convert([], test_util:as_selector(Selector)).
+
convert_fields_test() ->
?assertEqual(
{op_null, {[[<<"field">>], <<":">>, <<"null">>], <<"true">>}},
- convert([], as_selector(#{<<"field">> => null}))
+ convert_selector(#{<<"field">> => null})
),
?assertEqual(
{op_field, {[[<<"field">>], <<":">>, <<"boolean">>], <<"true">>}},
- convert([], as_selector(#{<<"field">> => true}))
+ convert_selector(#{<<"field">> => true})
),
?assertEqual(
{op_field, {[[<<"field">>], <<":">>, <<"number">>], <<"42">>}},
- convert([], as_selector(#{<<"field">> => 42}))
+ convert_selector(#{<<"field">> => 42})
),
?assertEqual(
{op_field, {[[<<"field">>], <<":">>, <<"string">>], <<"\"value\"">>}},
- convert([], as_selector(#{<<"field">> => <<"value">>}))
+ convert_selector(#{<<"field">> => <<"value">>})
),
?assertEqual(
{op_and, [
@@ -465,74 +464,74 @@ convert_fields_test() ->
{op_field, {[[<<"field">>, <<".">>, <<"[]">>], <<":">>, <<"number">>], <<"2">>}},
{op_field, {[[<<"field">>, <<".">>, <<"[]">>], <<":">>, <<"number">>], <<"3">>}}
]},
- convert([], as_selector(#{<<"field">> => [1, 2, 3]}))
+ convert_selector(#{<<"field">> => [1, 2, 3]})
),
?assertEqual(
{op_field, {
[[<<"field1">>, <<".">>, <<"field2">>], <<":">>, <<"string">>], <<"\"value\"">>
}},
- convert([], as_selector(#{<<"field1">> => #{<<"field2">> => <<"value">>}}))
+ convert_selector(#{<<"field1">> => #{<<"field2">> => <<"value">>}})
),
?assertEqual(
{op_and, [
{op_field, {[[<<"field2">>], <<":">>, <<"string">>], <<"\"value2\"">>}},
{op_field, {[[<<"field1">>], <<":">>, <<"string">>], <<"\"value1\"">>}}
]},
- convert([], as_selector(#{<<"field1">> => <<"value1">>, <<"field2">> => <<"value2">>}))
+ convert_selector(#{<<"field1">> => <<"value1">>, <<"field2">> => <<"value2">>})
).
convert_default_test() ->
?assertEqual(
{op_default, <<"\"text\"">>},
- convert([], as_selector(#{<<"$default">> => #{<<"$text">> => <<"text">>}}))
+ convert_selector(#{<<"$default">> => #{<<"$text">> => <<"text">>}})
).
convert_lt_test() ->
?assertEqual(
{op_field,
{[[<<"field">>], <<":">>, <<"number">>], [<<"[-Infinity TO ">>, <<"42">>, <<"}">>]}},
- convert([], as_selector(#{<<"field">> => #{<<"$lt">> => 42}}))
+ convert_selector(#{<<"field">> => #{<<"$lt">> => 42}})
),
?assertEqual(
{op_or, [
{op_fieldname, {[[<<"field">>], ":"], "*"}},
{op_fieldname, {[[<<"field">>]], ".*"}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$lt">> => [1, 2, 3]}}))
+ convert_selector(#{<<"field">> => #{<<"$lt">> => [1, 2, 3]}})
),
?assertEqual(
{op_or, [
{op_fieldname, {[[<<"field">>], ":"], "*"}},
{op_fieldname, {[[<<"field">>]], ".*"}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$lt">> => null}}))
+ convert_selector(#{<<"field">> => #{<<"$lt">> => null}})
).
convert_lte_test() ->
?assertEqual(
{op_field,
{[[<<"field">>], <<":">>, <<"number">>], [<<"[-Infinity TO ">>, <<"42">>, <<"]">>]}},
- convert([], as_selector(#{<<"field">> => #{<<"$lte">> => 42}}))
+ convert_selector(#{<<"field">> => #{<<"$lte">> => 42}})
),
?assertEqual(
{op_or, [
{op_fieldname, {[[<<"field">>], ":"], "*"}},
{op_fieldname, {[[<<"field">>]], ".*"}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$lte">> => [1, 2, 3]}}))
+ convert_selector(#{<<"field">> => #{<<"$lte">> => [1, 2, 3]}})
),
?assertEqual(
{op_or, [
{op_fieldname, {[[<<"field">>], ":"], "*"}},
{op_fieldname, {[[<<"field">>]], ".*"}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$lte">> => null}}))
+ convert_selector(#{<<"field">> => #{<<"$lte">> => null}})
).
convert_eq_test() ->
?assertEqual(
{op_field, {[[<<"field">>], <<":">>, <<"number">>], <<"42">>}},
- convert([], as_selector(#{<<"field">> => #{<<"$eq">> => 42}}))
+ convert_selector(#{<<"field">> => #{<<"$eq">> => 42}})
),
?assertEqual(
{op_and, [
@@ -541,11 +540,11 @@ convert_eq_test() ->
{op_field, {[[<<"field">>, <<".">>, <<"[]">>], <<":">>, <<"number">>], <<"2">>}},
{op_field, {[[<<"field">>, <<".">>, <<"[]">>], <<":">>, <<"number">>], <<"3">>}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$eq">> => [1, 2, 3]}}))
+ convert_selector(#{<<"field">> => #{<<"$eq">> => [1, 2, 3]}})
),
?assertEqual(
{op_null, {[[<<"field">>], <<":">>, <<"null">>], <<"true">>}},
- convert([], as_selector(#{<<"field">> => #{<<"$eq">> => null}}))
+ convert_selector(#{<<"field">> => #{<<"$eq">> => null}})
).
convert_ne_test() ->
@@ -557,49 +556,49 @@ convert_ne_test() ->
]},
{op_field, {[[<<"field">>], <<":">>, <<"number">>], <<"42">>}}
}},
- convert([], as_selector(#{<<"field">> => #{<<"$ne">> => 42}}))
+ convert_selector(#{<<"field">> => #{<<"$ne">> => 42}})
).
convert_gte_test() ->
?assertEqual(
{op_field,
{[[<<"field">>], <<":">>, <<"number">>], [<<"[">>, <<"42">>, <<" TO Infinity]">>]}},
- convert([], as_selector(#{<<"field">> => #{<<"$gte">> => 42}}))
+ convert_selector(#{<<"field">> => #{<<"$gte">> => 42}})
),
?assertEqual(
{op_or, [
{op_fieldname, {[[<<"field">>], ":"], "*"}},
{op_fieldname, {[[<<"field">>]], ".*"}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$gte">> => [1, 2, 3]}}))
+ convert_selector(#{<<"field">> => #{<<"$gte">> => [1, 2, 3]}})
),
?assertEqual(
{op_or, [
{op_fieldname, {[[<<"field">>], ":"], "*"}},
{op_fieldname, {[[<<"field">>]], ".*"}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$gte">> => null}}))
+ convert_selector(#{<<"field">> => #{<<"$gte">> => null}})
).
convert_gt_test() ->
?assertEqual(
{op_field,
{[[<<"field">>], <<":">>, <<"number">>], [<<"{">>, <<"42">>, <<" TO Infinity]">>]}},
- convert([], as_selector(#{<<"field">> => #{<<"$gt">> => 42}}))
+ convert_selector(#{<<"field">> => #{<<"$gt">> => 42}})
),
?assertEqual(
{op_or, [
{op_fieldname, {[[<<"field">>], ":"], "*"}},
{op_fieldname, {[[<<"field">>]], ".*"}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$gt">> => [1, 2, 3]}}))
+ convert_selector(#{<<"field">> => #{<<"$gt">> => [1, 2, 3]}})
),
?assertEqual(
{op_or, [
{op_fieldname, {[[<<"field">>], ":"], "*"}},
{op_fieldname, {[[<<"field">>]], ".*"}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$gt">> => null}}))
+ convert_selector(#{<<"field">> => #{<<"$gt">> => null}})
).
convert_all_test() ->
@@ -612,37 +611,31 @@ convert_all_test() ->
[[<<"field">>, <<".">>, <<"[]">>], <<":">>, <<"string">>], <<"\"value2\"">>
}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$all">> => [<<"value1">>, <<"value2">>]}}))
+ convert_selector(#{<<"field">> => #{<<"$all">> => [<<"value1">>, <<"value2">>]}})
).
convert_elemMatch_test() ->
?assertEqual(
{op_field, {[[<<"field">>, <<".">>, <<"[]">>], <<":">>, <<"string">>], <<"\"value\"">>}},
- convert(
- [], as_selector(#{<<"field">> => #{<<"$elemMatch">> => #{<<"$eq">> => <<"value">>}}})
- )
+ convert_selector(#{<<"field">> => #{<<"$elemMatch">> => #{<<"$eq">> => <<"value">>}}})
).
convert_allMatch_test() ->
?assertEqual(
{op_field, {[[<<"field">>, <<".">>, <<"[]">>], <<":">>, <<"string">>], <<"\"value\"">>}},
- convert(
- [], as_selector(#{<<"field">> => #{<<"$allMatch">> => #{<<"$eq">> => <<"value">>}}})
- )
+ convert_selector(#{<<"field">> => #{<<"$allMatch">> => #{<<"$eq">> => <<"value">>}}})
).
convert_keyMapMatch_test() ->
?assertThrow(
{mango_error, mango_selector_text, {invalid_operator, <<"$keyMapMatch">>}},
- convert(
- [], as_selector(#{<<"field">> => #{<<"$keyMapMatch">> => #{<<"key">> => <<"value">>}}})
- )
+ convert_selector(#{<<"field">> => #{<<"$keyMapMatch">> => #{<<"key">> => <<"value">>}}})
).
convert_in_test() ->
?assertEqual(
{op_or, []},
- convert([], as_selector(#{<<"field">> => #{<<"$in">> => []}}))
+ convert_selector(#{<<"field">> => #{<<"$in">> => []}})
),
?assertEqual(
{op_or, [
@@ -659,7 +652,7 @@ convert_in_test() ->
}}
]}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$in">> => [<<"value1">>, <<"value2">>]}}))
+ convert_selector(#{<<"field">> => #{<<"$in">> => [<<"value1">>, <<"value2">>]}})
).
convert_nin_test() ->
@@ -671,7 +664,7 @@ convert_nin_test() ->
]},
{op_or, []}
}},
- convert([], as_selector(#{<<"field">> => #{<<"$nin">> => []}}))
+ convert_selector(#{<<"field">> => #{<<"$nin">> => []}})
),
?assertEqual(
{op_not, {
@@ -690,7 +683,7 @@ convert_nin_test() ->
]}
]}
}},
- convert([], as_selector(#{<<"field">> => #{<<"$nin">> => [1, 2]}}))
+ convert_selector(#{<<"field">> => #{<<"$nin">> => [1, 2]}})
).
convert_exists_test() ->
@@ -699,7 +692,7 @@ convert_exists_test() ->
{op_fieldname, {[[<<"field">>], ":"], "*"}},
{op_fieldname, {[[<<"field">>]], ".*"}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$exists">> => true}}))
+ convert_selector(#{<<"field">> => #{<<"$exists">> => true}})
),
?assertEqual(
{op_not, {
@@ -709,7 +702,7 @@ convert_exists_test() ->
]},
false
}},
- convert([], as_selector(#{<<"field">> => #{<<"$exists">> => false}}))
+ convert_selector(#{<<"field">> => #{<<"$exists">> => false}})
).
convert_type_test() ->
@@ -718,25 +711,25 @@ convert_type_test() ->
{op_fieldname, {[[<<"field">>], ":"], "*"}},
{op_fieldname, {[[<<"field">>]], ".*"}}
]},
- convert([], as_selector(#{<<"field">> => #{<<"$type">> => <<"string">>}}))
+ convert_selector(#{<<"field">> => #{<<"$type">> => <<"string">>}})
).
convert_mod_test() ->
?assertEqual(
{op_fieldname, {[[<<"field">>], ":"], "number"}},
- convert([], as_selector(#{<<"field">> => #{<<"$mod">> => [2, 0]}}))
+ convert_selector(#{<<"field">> => #{<<"$mod">> => [2, 0]}})
).
convert_regex_test() ->
?assertEqual(
{op_regex, [<<"field">>]},
- convert([], as_selector(#{<<"field">> => #{<<"$regex">> => <<".*">>}}))
+ convert_selector(#{<<"field">> => #{<<"$regex">> => <<".*">>}})
).
convert_size_test() ->
?assertEqual(
{op_field, {[[<<"field">>, <<".">>, <<"[]">>], <<":length">>], <<"6">>}},
- convert([], as_selector(#{<<"field">> => #{<<"$size">> => 6}}))
+ convert_selector(#{<<"field">> => #{<<"$size">> => 6}})
).
convert_not_test() ->
@@ -748,57 +741,51 @@ convert_not_test() ->
]},
{op_fieldname, {[[<<"field">>], ":"], "number"}}
}},
- convert([], as_selector(#{<<"field">> => #{<<"$not">> => #{<<"$mod">> => [2, 0]}}}))
+ convert_selector(#{<<"field">> => #{<<"$not">> => #{<<"$mod">> => [2, 0]}}})
).
convert_and_test() ->
?assertEqual(
{op_and, []},
- convert([], as_selector(#{<<"$and">> => []}))
+ convert_selector(#{<<"$and">> => []})
),
?assertEqual(
{op_and, [{op_field, {[[<<"field">>], <<":">>, <<"string">>], <<"\"value\"">>}}]},
- convert([], as_selector(#{<<"$and">> => [#{<<"field">> => <<"value">>}]}))
+ convert_selector(#{<<"$and">> => [#{<<"field">> => <<"value">>}]})
),
?assertEqual(
{op_and, [
{op_field, {[[<<"field1">>], <<":">>, <<"string">>], <<"\"value1\"">>}},
{op_field, {[[<<"field2">>], <<":">>, <<"string">>], <<"\"value2\"">>}}
]},
- convert(
- [],
- as_selector(#{
- <<"$and">> => [#{<<"field1">> => <<"value1">>}, #{<<"field2">> => <<"value2">>}]
- })
- )
+ convert_selector(#{
+ <<"$and">> => [#{<<"field1">> => <<"value1">>}, #{<<"field2">> => <<"value2">>}]
+ })
).
convert_or_test() ->
?assertEqual(
{op_or, []},
- convert([], as_selector(#{<<"$or">> => []}))
+ convert_selector(#{<<"$or">> => []})
),
?assertEqual(
{op_or, [{op_field, {[[<<"field">>], <<":">>, <<"string">>], <<"\"value\"">>}}]},
- convert([], as_selector(#{<<"$or">> => [#{<<"field">> => <<"value">>}]}))
+ convert_selector(#{<<"$or">> => [#{<<"field">> => <<"value">>}]})
),
?assertEqual(
{op_or, [
{op_field, {[[<<"field1">>], <<":">>, <<"string">>], <<"\"value1\"">>}},
{op_field, {[[<<"field2">>], <<":">>, <<"string">>], <<"\"value2\"">>}}
]},
- convert(
- [],
- as_selector(#{
- <<"$or">> => [#{<<"field1">> => <<"value1">>}, #{<<"field2">> => <<"value2">>}]
- })
- )
+ convert_selector(#{
+ <<"$or">> => [#{<<"field1">> => <<"value1">>}, #{<<"field2">> => <<"value2">>}]
+ })
).
convert_nor_test() ->
?assertEqual(
{op_and, []},
- convert([], as_selector(#{<<"$nor">> => []}))
+ convert_selector(#{<<"$nor">> => []})
),
?assertEqual(
{op_and, [
@@ -810,7 +797,7 @@ convert_nor_test() ->
{op_field, {[[<<"field">>], <<":">>, <<"string">>], <<"\"value\"">>}}
}}
]},
- convert([], as_selector(#{<<"$nor">> => [#{<<"field">> => <<"value">>}]}))
+ convert_selector(#{<<"$nor">> => [#{<<"field">> => <<"value">>}]})
),
?assertEqual(
{op_and, [
@@ -829,12 +816,9 @@ convert_nor_test() ->
{op_field, {[[<<"field2">>], <<":">>, <<"string">>], <<"\"value2\"">>}}
}}
]},
- convert(
- [],
- as_selector(#{
- <<"$nor">> => [#{<<"field1">> => <<"value1">>}, #{<<"field2">> => <<"value2">>}]
- })
- )
+ convert_selector(#{
+ <<"$nor">> => [#{<<"field1">> => <<"value1">>}, #{<<"field2">> => <<"value2">>}]
+ })
).
to_query_test() ->