Stored attribute whose value is an empty array stores nil, instead of an empty array
Reported by Toby Matejovsky | May 14th, 2010 @ 11:40 AM | in Wishlist
When an array value is stored, whose block evaluates to an empty array, nil is stored instead of an empty array. This is counterintuitive and requires the user to run a nil check on the stored "array" instead of assuming that the result will always be an array, e.g.:
# would FAIL if stored value comes back as nil, instead of empty array
hit.stored(:array_or_nil).each { ... do something ... }
Given this setup:
searchable do
text :foo, :stored => true do
[]
end
text :bar, :stored => true do
%w( yaba daba doo )
end
end
# EXPECTED
hit.stored(:foo) => []
hit.stored(:var) => ["yaba", "daba", "doo"]
# ACTUAL
hit.stored(:foo) => nil
hit.stored(:var) => ["yaba", "daba", "doo"]
Comments and changes to this ticket
-

mat July 14th, 2010 @ 11:24 AM
- Milestone set to Bugs
- Milestone order changed from 0 to 0
-

mat July 14th, 2010 @ 03:28 PM
- Tag changed from array, nil, stored to stored
There isn't an easy-win solution to this, so I've opened up a discussion on the group:
http://groups.google.com/group/ruby-sunspot/browse_thread/thread/87...
-

mat December 27th, 2010 @ 02:22 PM
- Milestone changed from Bugs to Wishlist
- Tag changed from stored to bug
- Milestone order changed from 22 to 0
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Awesome Solr interaction for Ruby