Skip to content

3.2.0: Regression in .where? #280

@nialbima

Description

@nialbima

Hiya!

SYSTEM INFO:
Rails: 6.1.7.1
Ruby: 3.0.4

Old version of ActiveHash: 3.1.1
New version: 3.2.0

I'm working on updating our version of ActiveHash to 3.2 from 3.1.1. We use this gem extensively because it's great, and it's usually this (example is not direct from our app, but is structured the same way):

class Disposition < ActiveHash::Base
  include ActiveHash::Enum

  enum_accessor :name
  self.data = [
    {
      id: 1,
      name: :a_disposition,
      display: true,
    },
    {
      id: 2,
      name: :another_disposition,
      display: false,
    },
  ]
end

We have a lot of code that uses .where to filter our dictionaries: Disposition.where(display: true). This is still locating the correct records, but some of the changes to .where in 3.2.0 seem to have broken our ability to call .map(&:name) on those records. I'm expecting to see an array of names associated with our dictionary, and am getting this as output:

#<Disposition:0x00000001418dd4b0>#<Disposition:0x00000001418dcab0>#<Disposition:0x00000001418dc5b0>#<Disposition:0x00000001418d7ec0>#<Disposition:0x00000001418d7858>#<Disposition:0x00000001418d71c8>#<Disposition:0x00000001418d6c50>=> []

I can get the expected list by going via .all or calling .all_records on the output, but I was surprised to see this breaking on us during my upgrade.

Is this a bug? Did something change here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions