mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
quoted_table_name
doesn't respect table alias
So using `arel_attribute(primary_key).asc` in `batch_order` instead.
This commit is contained in:
parent
7d5399379c
commit
6a4c02b850
2 changed files with 12 additions and 1 deletions
|
@ -271,7 +271,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def batch_order
|
||||
"#{quoted_table_name}.#{quoted_primary_key} ASC"
|
||||
arel_attribute(primary_key).asc
|
||||
end
|
||||
|
||||
def act_on_ignored_order(error_on_ignore)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue