提交 d1099540 编写于 作者: J Jon Leighton

Deprecate Relation#all.

It has been moved to active_record_deprecated_finders.

Use #to_a instead.
上级 b658cf11
......@@ -171,7 +171,7 @@ def delete_through_records(records)
def find_target
return [] unless target_reflection_has_associated_record?
scoped.all
scoped.to_a
end
# NOTE - not sure that we can actually cope with inverses here
......
......@@ -490,7 +490,7 @@ def structure_dump
def dump_schema_information #:nodoc:
sm_table = ActiveRecord::Migrator.schema_migrations_table_name
ActiveRecord::SchemaMigration.order('version').all.map { |sm|
ActiveRecord::SchemaMigration.order('version').map { |sm|
"INSERT INTO #{sm_table} (version) VALUES ('#{sm.version}');"
}.join "\n\n"
end
......
......@@ -67,7 +67,7 @@ def find_in_batches(options = {})
batch_size = options.delete(:batch_size) || 1000
relation = relation.reorder(batch_order).limit(batch_size)
records = relation.where(table[primary_key].gteq(start)).all
records = relation.where(table[primary_key].gteq(start)).to_a
while records.any?
records_size = records.size
......
......@@ -133,19 +133,6 @@ def last!
last or raise RecordNotFound
end
# Runs the query on the database and returns records with the used query
# methods.
#
# Person.all # returns an array of objects for all the rows fetched by SELECT * FROM people
# Person.where(["category IN (?)", categories]).limit(50).all
# Person.where({ :friends => ["Bob", "Steve", "Fred"] }).all
# Person.offset(10).limit(10).all
# Person.includes([:account, :friends]).all
# Person.group("category").all
def all
to_a
end
# Returns +true+ if a record exists in the table that matches the +id+ or
# conditions given, or +false+ otherwise. The argument can take six forms:
#
......@@ -285,7 +272,7 @@ def find_one(id)
end
def find_some(ids)
result = where(table[primary_key].in(ids)).all
result = where(table[primary_key].in(ids)).to_a
expected_size =
if limit_value && ids.size > limit_value
......
......@@ -86,7 +86,7 @@ def test_bad_collection_keys
def test_should_construct_new_finder_sql_after_create
person = Person.new :first_name => 'clark'
assert_equal [], person.readers.all
assert_equal [], person.readers.to_a
person.save!
reader = Reader.create! :person => person, :post => Post.new(:title => "foo", :body => "bar")
assert person.readers.find(reader.id)
......
......@@ -71,13 +71,13 @@ def test_has_many_with_through_is_not_implicitly_marked_readonly_while_finding_l
end
def test_readonly_scoping
Post.where('1=1').all do
Post.where('1=1').scoping do
assert !Post.find(1).readonly?
assert Post.readonly(true).find(1).readonly?
assert !Post.readonly(false).find(1).readonly?
end
Post.joins(' ').all do
Post.joins(' ').scoping do
assert !Post.find(1).readonly?
assert Post.readonly.find(1).readonly?
assert !Post.readonly(false).find(1).readonly?
......@@ -86,14 +86,14 @@ def test_readonly_scoping
# Oracle barfs on this because the join includes unqualified and
# conflicting column names
unless current_adapter?(:OracleAdapter)
Post.joins(', developers').all do
Post.joins(', developers').scoping do
assert Post.find(1).readonly?
assert Post.readonly.find(1).readonly?
assert !Post.readonly(false).find(1).readonly?
end
end
Post.readonly(true).all do
Post.readonly(true).scoping do
assert Post.find(1).readonly?
assert Post.readonly.find(1).readonly?
assert !Post.readonly(false).find(1).readonly?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册