#118 new
Toby Matejovsky

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
      text :bar, :stored => true do
        %w( yaba daba doo )
    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

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.

New-ticket Create new ticket

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

People watching this ticket