Skip to content
Snippets Groups Projects
Unverified Commit 88b9ee0f authored by lbrdnk's avatar lbrdnk Committed by GitHub
Browse files

Update mongo native param substitution (#33003)


Change is compatible with prior implementation. Match clause like
the following, `{$match: {"something": "Facebook"}}`, does exact match
if `something` is a scalar, and in case `something` was an array, match
would check whether it contains the `Facebook` value. Same behavior,
as with `{$match: {"something": {$in: ["Facebook"]}}}`.

Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
parent 16c74a59
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,10 @@
(defn- param-value->str
[{coercion :coercion_strategy, :as field} x]
(cond
;; #30136: Provide a way of using dashboard filter as a variable.
(and (sequential? x) (= (count x) 1))
(recur field (first x))
;; sequences get converted to `$in`
(sequential? x)
(format "{$in: [%s]}" (str/join ", " (map (partial param-value->str field) x)))
......
......@@ -96,8 +96,8 @@
(is (= "{$in: [1, 2, 3]}"
(substitute {:id [1 2 3]}
[(param :id)]))))
(testing "multiple-values single (#22486)"
(is (= "{$in: [\"33 Taps\"]}"
(testing "multiple-values single (#30136)"
(is (= "\"33 Taps\""
(substitute {:id ["33 Taps"]}
[(param :id)]))))
(testing "multiple-values multi (#22486)"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment