aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-05-21 15:00:41 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-05-21 23:41:13 +0900
commit82a54be0c6a19336008e18f52bc76791adc3bd67 (patch)
tree801e0ffb599536daa8bf7f331a2ef9994d54159c /activerecord/test/cases
parent0810c076de0d9b7879ee240bb08d31fb7c2f5ac9 (diff)
downloadrails-82a54be0c6a19336008e18f52bc76791adc3bd67.tar.gz
rails-82a54be0c6a19336008e18f52bc76791adc3bd67.tar.bz2
rails-82a54be0c6a19336008e18f52bc76791adc3bd67.zip
Fall back to type casting from the connection adapter
Unfortunately, a11a8ff had no effect as long as using bind param, and was not tested. This ensures making the intent of a11a8ff, which fall back to type casting from the connection adapter. Fixes #35205. ``` % ARCONN=postgresql bundle exec ruby -w -Itest test/cases/relation/where_test.rb -n test_type_casting_nested_joins Using postgresql Run options: -n test_type_casting_nested_joins --seed 55730 # Running: E Error: ActiveRecord::WhereTest#test_type_casting_nested_joins: ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "2-foo" rails test test/cases/relation/where_test.rb:30 Finished in 0.245778s, 4.0687 runs/s, 0.0000 assertions/s. 1 runs, 0 assertions, 0 failures, 1 errors, 0 skips ```
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/relation/where_test.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/test/cases/relation/where_test.rb b/activerecord/test/cases/relation/where_test.rb
index 6c1e3e7fec..aad30ddea0 100644
--- a/activerecord/test/cases/relation/where_test.rb
+++ b/activerecord/test/cases/relation/where_test.rb
@@ -18,7 +18,7 @@ require "support/stubs/strong_parameters"
module ActiveRecord
class WhereTest < ActiveRecord::TestCase
- fixtures :posts, :edges, :authors, :author_addresses, :binaries, :essays, :cars, :treasures, :price_estimates, :topics
+ fixtures :posts, :comments, :edges, :authors, :author_addresses, :binaries, :essays, :cars, :treasures, :price_estimates, :topics
def test_in_clause_is_correctly_sliced
assert_called(Author.connection, :in_clause_length, returns: 1) do
@@ -27,6 +27,11 @@ module ActiveRecord
end
end
+ def test_type_casting_nested_joins
+ comment = comments(:eager_other_comment1)
+ assert_equal [comment], Comment.joins(post: :author).where(authors: { id: "2-foo" })
+ end
+
def test_where_copies_bind_params
author = authors(:david)
posts = author.posts.where("posts.id != 1")