mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #19755 from yuki24/activerecord/support-for-set
Add support for Set to Relation#where
This commit is contained in:
commit
524d40591e
3 changed files with 15 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
* Add support for `Set` to `Relation#where`.
|
||||
|
||||
*Yuki Nishijima*
|
||||
|
||||
* Fixed a bug where uniqueness validations would error on out of range values,
|
||||
even if an validation should have prevented it from hitting the database.
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ module ActiveRecord
|
|||
register_handler(Range, RangeHandler.new(self))
|
||||
register_handler(Relation, RelationHandler.new)
|
||||
register_handler(Array, ArrayHandler.new(self))
|
||||
register_handler(Set, ArrayHandler.new(self))
|
||||
register_handler(AssociationQueryValue, AssociationQueryHandler.new(self))
|
||||
end
|
||||
|
||||
|
|
|
@ -848,6 +848,16 @@ class RelationTest < ActiveRecord::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_find_all_using_where_with_a_set
|
||||
david = authors(:david)
|
||||
mary = authors(:mary)
|
||||
set = Set.new([david.id, mary.id])
|
||||
|
||||
assert_queries(1) {
|
||||
assert_equal [david, mary], Author.where(id: set).to_a
|
||||
}
|
||||
end
|
||||
|
||||
def test_exists
|
||||
davids = Author.where(:name => 'David')
|
||||
assert davids.exists?
|
||||
|
|
Loading…
Reference in a new issue