Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1142

Criteria for a nil array generates an error

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.1.8
    • Affects Version/s: None
    • Component/s: None

      This shouldn't happen:

      class Address 
        include Mongoid::Document 
        field :name 
        field :tags, :type => Array 
      end
      
      Address.where :tags => nil
      NoMethodError: undefined method `new' for NilClass:Class
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.1.7/lib/mongoid/serialization.rb:53:in `mongoize'
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.1.7/lib/mongoid/criterion/selector.rb:116:in `typecast_value_for'
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.1.7/lib/mongoid/criterion/selector.rb:88:in `try_to_typecast'
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.1.7/lib/mongoid/criterion/selector.rb:33:in `[]='
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.1.7/lib/mongoid/criterion/inclusion.rb:170:in `block (2 levels) in where'
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.1.7/lib/mongoid/criterion/inclusion.rb:161:in `each_pair'
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.1.7/lib/mongoid/criterion/inclusion.rb:161:in `block in where'
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.1.7/lib/mongoid/criterion/inclusion.rb:154:in `tap'
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.1.7/lib/mongoid/criterion/inclusion.rb:154:in `where'
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongoid-2.1.7/lib/mongoid/finders.rb:14:in `where'
              from (irb):16
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.4/lib/rails/commands/console.rb:44:in `start'
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.4/lib/rails/commands/console.rb:8:in `start'
              from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.4/lib/rails/commands.rb:23:in `<top (required)>'
              from script/rails:6:in `require'
              from script/rails:6:in `<main>'
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            nickh Nick Hoffman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: