Exception: Mongoid::Errors::InvalidQuery

Inherits:
MongoidError
  • Object
show all
Defined in:
build/mongoid-7.3/lib/mongoid/errors/invalid_query.rb

Overview

Raised when invalid query is passed to an embedded matcher, or an invalid query fragment is passed to the query builder (Criteria object).

Constant Summary

Constants inherited from MongoidError

MongoidError::BASE_KEY

Instance Attribute Summary

Attributes inherited from MongoidError

#problem, #resolution, #summary

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MongoidError

#compose_message

Constructor Details

#initialize(msg) ⇒ InvalidQuery

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create the new invalid query error.



14
15
16
# File 'build/mongoid-7.3/lib/mongoid/errors/invalid_query.rb', line 14

def initialize(msg)
  super
end

Class Method Details

.truncate_expr(expr) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Stringifies the argument using #inspect and truncates the result to about 100 characters.

Parameters:

  • expr (Object)

    An expression to stringify and truncate.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'build/mongoid-7.3/lib/mongoid/errors/invalid_query.rb', line 24

def self.truncate_expr(expr)
  unless expr.is_a?(String)
    expr = expr.inspect
  end

  if expr.length > 103
    expr = if expr =~ /\A<#((?:.|\n)*)>\z/
      "<##{expr.slice(0, 97)}...>"
    else
      expr.slice(0, 100) + '...'
    end
  end

  expr
end