Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

where(undefined_key: nil) returns relation including all records #190

Open
unhappychoice opened this issue Dec 5, 2019 · 0 comments
Open

Comments

@unhappychoice
Copy link

unhappychoice commented Dec 5, 2019

Description

Now, where(undefined_key: nil) returns all records.
But I think where(undefined_key: nil) should raise an error because

  • It's same as ActiveRecord behavior.
  • We cannot recognize typo and get a surprising result.

Code to reproduce

class Records < ActiveHash::Base
  self.data = [
    { id: 1, name: 'foo' },
    { id: 2, name: 'bar' },
    { id: 3, name: 'baz' }
  ]
end

pp Records.where(undefined_key: nil).to_a
# [
#    #<Records:0x00007fadaf51a5e0 @attributes={:id=>1, :name=>"foo"}>,
#    #<Records:0x00007fadaf519988 @attributes={:id=>2, :name=>"bar"}>,
#   #<Records:0x00007fadaf519348 @attributes={:id=>3, :name=>"baz"}>
# ]

Other informations

  • This will be breaking change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant