Skip to content

Fix the behavior when passing nil to exists?#320

Merged
kbrock merged 1 commit intoactive-hash:masterfrom
y-yagi:fix_exists
Aug 27, 2024
Merged

Fix the behavior when passing nil to exists?#320
kbrock merged 1 commit intoactive-hash:masterfrom
y-yagi:fix_exists

Conversation

@y-yagi
Copy link
Contributor

@y-yagi y-yagi commented Aug 27, 2024

Currently, the behavior when passing nil to exists? doesn't match with Rails's behavior. Rails always returns false, but ActiveHash not. https://github.com/rails/rails/blob/5a0b2fa5a3be6ffd49fa7f1c3544c1da403c9cb5/activerecord/lib/active_record/relation/finder_methods.rb#L367

This PR changes the behavior to match with Rails's.

Currently, the behavior when passing `nil` to `exists?` doesn't match
with Rails's behavior. Rails always returns `false`, but ActiveHash not.
https://github.com/rails/rails/blob/5a0b2fa5a3be6ffd49fa7f1c3544c1da403c9cb5/activerecord/lib/active_record/relation/finder_methods.rb#L367

This PR changes the behavior to match with Rails's.
@y-yagi y-yagi marked this pull request as ready for review August 27, 2024 05:51
@kbrock
Copy link
Collaborator

kbrock commented Aug 27, 2024

thank you @y-yagi

@kbrock kbrock merged commit a192385 into active-hash:master Aug 27, 2024
@kbrock kbrock added the bug label Aug 27, 2024
@y-yagi y-yagi deleted the fix_exists branch August 28, 2024 00:36
kbrock added a commit to kbrock/active_hash that referenced this pull request Jul 29, 2025
- Add i18n support active-hash#230 @ryu-sato
- Add `column_names` method active-hash#311 @hatsu38
- Support Active Record 7.2 active-hash#317 @ashleyHutton
- Support ruby 3.4 active-hash#328 @flavorjones
- Add `:alias` to `has_many :through` active-hash#329 @alexgriff
- Add Active Record 8.0 active-hash#324 @flavorjones

- Fix Do not suppress load errors#309 @andreynering
- Ensure `field_names` are all strings active-hash#312 @flavorjones
- Hide private `add_default_value` active-hash#314 @kbrock
- Fix `exists?(nil)` active-hash#320 @y-yagi
- Enance Enum support active-hash#321 @hatsu38
- Updated docs active-hash#326 @y-yagi

- Drop Active Record < 6.1. Ruby < 3.0 active-hash#324 @flavorjones
kbrock added a commit to kbrock/active_hash that referenced this pull request Jul 29, 2025
Added
=====

- Add i18n support active-hash#230 @ryu-sato
- Add `column_names` method active-hash#311 @hatsu38
- Support Active Record 7.2 active-hash#317 @ashleyHutton
- Support ruby 3.4 active-hash#328 @flavorjones
- Add `:alias` to `has_many :through` active-hash#329 @alexgriff
- Add Active Record 8.0 active-hash#324 @flavorjones

Fixed
=====

- Fix Do not suppress load errors#309 @andreynering
- Ensure `field_names` are all strings active-hash#312 @flavorjones
- Hide private `add_default_value` active-hash#314 @kbrock
- Fix `exists?(nil)` active-hash#320 @y-yagi
- Enance Enum support active-hash#321 @hatsu38
- Updated docs active-hash#326 @y-yagi

Removed
=======

- Drop Active Record < 6.1. Ruby < 3.0 active-hash#324 @flavorjones
@kbrock kbrock mentioned this pull request Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants