ryanong/mongoid_spacial

Setting a spacial field to nil fails

Closed this issue · 1 comments

While trying to set a spatial field to nil I get the following

field :search_location, type: Array, spacial: true

def blah
x.search_location = nil
end

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
from /Users/mwawrusch/.rvm/gems/ruby-1.9.2-p290@triponadeal/gems/mongoid_spacial-0.2.12/lib/mongoid_spacial/field_option.rb:32:in `block (3 levels)

x.search_location = [nil,nil] works, although I do not know if this is correct. It also looks bad and is counter intuitive.

elia commented

Which version of mongodb are you using?

My mongodb v2.0.0 raises 13654: location object expected, location array not in correct format when receives [nil,nil] on an indexed spacial field, but works when I pass nil directly.