aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-18 15:27:23 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-02-18 16:57:10 +0900
commitb09d8f6bb3a23cd907d084103fb5b4c02479a39b (patch)
tree150e5356911c2cb1e4576a9190d1269e268f7145 /activerecord/test/cases/relation
parent4ea067017ae52d4a74335ed85df085a86663d213 (diff)
downloadrails-b09d8f6bb3a23cd907d084103fb5b4c02479a39b.tar.gz
rails-b09d8f6bb3a23cd907d084103fb5b4c02479a39b.tar.bz2
rails-b09d8f6bb3a23cd907d084103fb5b4c02479a39b.zip
Don't allow `where` with invalid value matches to nil values
That is considered as silently leaking information. If type casting doesn't return any actual value, it should not be matched to any record. Fixes #33624. Closes #33946.
Diffstat (limited to 'activerecord/test/cases/relation')
-rw-r--r--activerecord/test/cases/relation/where_test.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/test/cases/relation/where_test.rb b/activerecord/test/cases/relation/where_test.rb
index d49ed092b2..bec204643b 100644
--- a/activerecord/test/cases/relation/where_test.rb
+++ b/activerecord/test/cases/relation/where_test.rb
@@ -50,8 +50,12 @@ module ActiveRecord
assert_equal [chef], chefs.to_a
end
- def test_where_with_casted_value_is_nil
- assert_equal 4, Topic.where(last_read: "").count
+ def test_where_with_invalid_value
+ topics(:first).update!(written_on: nil, bonus_time: nil, last_read: nil)
+ assert_empty Topic.where(parent_id: Object.new)
+ assert_empty Topic.where(written_on: "")
+ assert_empty Topic.where(bonus_time: "")
+ assert_empty Topic.where(last_read: "")
end
def test_rewhere_on_root