mongodb/mongoid · error · Mongoid::Errors::UnsupportedJavascript

Errors::UnsupportedJavascript.new(klass, expression)

Error message

Errors::UnsupportedJavascript.new(klass, expression)

What it means

Error "Errors::UnsupportedJavascript.new(klass, expression)" thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/criteria.rb:522

    #   or javascript string.
    #
    # @raise [ UnsupportedJavascript ] If provided a string and the criteria
    #   is embedded.
    #
    # @return [ Criteria ] The cloned selectable.
    def where(*args)
      # Historically this method required exactly one argument.
      # As of https://jira.mongodb.org/browse/MONGOID-4804 it also accepts
      # zero arguments.
      # The underlying where implementation that super invokes supports
      # any number of arguments, but we don't presently allow multiple
      # arguments through this method. This API can be reconsidered in the
      # future.
      raise ArgumentError, "Criteria#where requires zero or one arguments (given #{args.length})" if args.length > 1

      if args.length == 1
        expression = args.first
        raise Errors::UnsupportedJavascript.new(klass, expression) if expression.is_a?(::String) && embedded?
      end
      super
    end

    # Get a version of this criteria without the options.
    #
    # @example Get the criteria without options.
    #   criteria.without_options
    #
    # @return [ Criteria ] The cloned criteria.
    def without_options
      crit = clone
      crit.options.clear
      crit
    end

    # Find documents by the provided javascript and scope. Uses a $where but is
    # different from +Criteria#where+ in that it will pass a code object to the

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/criteria.rb:522 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/5c432590795314f6. Report an issue: GitHub.