Skip to content

Commit

Permalink
MONGOID-4906 Implement $comment (#4921)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksadoff authored Nov 18, 2020
1 parent d8ef286 commit 3839fc4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/mongoid/matcher/expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ module Expression
end
expr.all? do |k, expr_v|
k = k.to_s
if k == "$comment"
# Nothing
return true
end
if k.start_with?('$')
ExpressionOperator.get(k).matches?(document, expr_v)
else
Expand Down
22 changes: 22 additions & 0 deletions spec/integration/matcher_operator_data/comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- name: matches
document:
name: Angel Share
query:
name: Angel Share
$comment: "foo"
matches: true

- name: null query is accepted
document:
pi: 3.14
query:
$comment: "hello"
matches: true

- name: does not match
document:
name: Angel Share
query:
name: Angel Foo
$comment: "foo"
matches: false

0 comments on commit 3839fc4

Please sign in to comment.