diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-14 07:51:28 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-14 07:53:15 +0900 |
commit | 6a4c02b850396b9d9e6f3ec8828b613459b71223 (patch) | |
tree | 9e4bb55181e16241b4fc0766bdb45a4c366d2150 /activerecord/test | |
parent | 7d5399379cb9ac2d3ffafa28fdc844d7b6c18ab8 (diff) | |
download | rails-6a4c02b850396b9d9e6f3ec8828b613459b71223.tar.gz rails-6a4c02b850396b9d9e6f3ec8828b613459b71223.tar.bz2 rails-6a4c02b850396b9d9e6f3ec8828b613459b71223.zip |
`quoted_table_name` doesn't respect table alias
So using `arel_attribute(primary_key).asc` in `batch_order` instead.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/batches_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb index 53c1e61ad1..c965404b07 100644 --- a/activerecord/test/cases/batches_test.rb +++ b/activerecord/test/cases/batches_test.rb @@ -614,6 +614,17 @@ class EachTest < ActiveRecord::TestCase assert_equal expected, actual end + test ".find_each respects table alias" do + assert_queries(1) do + table_alias = Post.arel_table.alias("omg_posts") + table_metadata = ActiveRecord::TableMetadata.new(Post, table_alias) + predicate_builder = ActiveRecord::PredicateBuilder.new(table_metadata) + + posts = ActiveRecord::Relation.create(Post, table_alias, predicate_builder) + posts.find_each {} + end + end + test ".find_each bypasses the query cache for its own queries" do Post.cache do assert_queries(2) do |