mongodb/mongoid · error · Mongoid::Errors::InvalidQuery
'$ne' operator does not allow Regexp arguments: #{Errors::In
Error message
'$ne' operator does not allow Regexp arguments: #{Errors::InvalidQuery.truncate_expr(condition)} What it means
Error "'$ne' operator does not allow Regexp arguments: #{Errors::InvalidQuery.truncate_expr(condition)}" thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/matcher/ne.rb:21
# In-memory matcher for $ne expression.
#
# @see https://www.mongodb.com/docs/manual/reference/operator/query/ne/
#
# @api private
module Ne
# Returns whether a value satisfies an $ne expression.
#
# @param [ true | false ] exists Whether the value exists.
# @param [ Object ] value The value to check.
# @param [ Object ] condition The $ne condition predicate.
#
# @return [ true | false ] Whether the value matches.
#
# @api private
module_function def matches?(exists, value, condition)
case condition
when ::Regexp, BSON::Regexp::Raw
raise Errors::InvalidQuery, "'$ne' operator does not allow Regexp arguments: #{Errors::InvalidQuery.truncate_expr(condition)}"
end
!EqImpl.matches?(exists, value, condition, '$ne')
end
end
end
end
View on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/matcher/ne.rb:21 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mongodb/mongoid@0da0e23d71 (2026-08-23).
Data as JSON: /api/errors/e7087efe4039cf0f.
Report an issue: GitHub.