Commit Graph

18 Commits

Author SHA1 Message Date
Arun Agrawal
76e94016a4 Sort here to make sure the order is ok. 2011-09-05 12:49:34 +05:30
Arun Agrawal
9066e34025 We need to recorder here. Need to drop the order from default scope.
Fixes #2832
2011-09-05 00:12:57 +05:30
Santiago Pastorino
d632e927ec Merge pull request #1807 from caius/find_in_batches_id_bug
Bugfix by stopping find_in_batches using the records after yielding.
2011-07-14 07:57:04 -07:00
knapo
2ca9b6dfab Make ActiveRecord::Batches#find_each to not return self.
This caused that `find_each` was producing extra db call taking all the records from db, and was less efficient than `ActiveRecord::Base#all`.
2011-07-07 11:40:11 +02:00
Caius Durling
96be08de25 Stop find_in_batches using the records after yielding.
Currently if the code that calls .find_in_batches modifies the yielded array in place then .find_in_batches can enter an infinite loop searching with ruby object ids in the database instead of the primary key of records in the database. This happens because it naively assumes the yielded array hasn't been modified before calling #id on the last object in the array. And ruby (1.8 at least) alias' #id to #object_id so an integer is still returned no matter what the last object is.

By moving finding the #id of the last object before yielding the array it means the calling code can do whatever it wants to the array in terms of modifying it in place, and .find_in_batches doesn't care.
2011-06-21 19:55:21 +01:00
Aaron Patterson
61774e0d49 please use ruby -I lib:test path/to/test.rb, or export RUBY_OPT 2011-06-06 15:47:13 -07:00
Jon Leighton
253bb6b926 Refactor Active Record test connection setup. Please see the RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases. 2011-06-04 23:47:03 +01:00
Andrew White
555d016389 Quote find_in_batches ORDER BY clause [#6620 state:resolved] 2011-03-29 17:24:55 +01:00
Jon Leighton
735844db71 Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/association_preload.rb
	activerecord/lib/active_record/associations.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
	activerecord/lib/active_record/associations/has_many_association.rb
	activerecord/lib/active_record/associations/has_many_through_association.rb
	activerecord/lib/active_record/associations/has_one_association.rb
	activerecord/lib/active_record/associations/has_one_through_association.rb
	activerecord/lib/active_record/associations/through_association_scope.rb
	activerecord/lib/active_record/reflection.rb
	activerecord/test/cases/associations/has_many_through_associations_test.rb
	activerecord/test/cases/associations/has_one_through_associations_test.rb
	activerecord/test/cases/reflection_test.rb
	activerecord/test/cases/relations_test.rb
	activerecord/test/fixtures/memberships.yml
	activerecord/test/models/categorization.rb
	activerecord/test/models/category.rb
	activerecord/test/models/member.rb
	activerecord/test/models/reference.rb
	activerecord/test/models/tagging.rb
2011-03-04 09:30:27 +00:00
Aaron Patterson
1e9685f159 preheat the table cache in arel 2011-01-14 11:16:31 -08:00
Jon Leighton
9ec0734874 Properly support conditions on any of the reflections involved in a nested through association 2010-10-19 00:27:40 +01:00
Jon Leighton
43711083dd Fix the tests (I have actually verified that these are also the 'right' fixes, rather than just making the tests pass again) 2010-10-03 11:56:32 +01:00
Josh Kalderimis
231d7676f7 corrected AR find_each and find_in_batches to raise when the user uses select but does not specify the primary key
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-09 13:14:47 +03:00
Emilio Tagua
53ddbfc460 Warn scoped order and limit are ignored. [#4123 state:resolved] 2010-03-29 11:30:06 -03:00
Pratik Naik
83f24afd44 Add new finder methods to association collection. 2009-12-27 00:25:00 +05:30
Pratik Naik
106976df09 Ensure ActiveRecord::Base.find_in_batches fires doesnt fire an extra query unless needed 2009-03-11 15:24:30 +00:00
Pratik Naik
04333482bd Rename ActiveRecord::Base.each to ActiveRecord::Base.find_each 2009-03-11 15:07:23 +00:00
David Heinemeier Hansson
d13623ca46 Added ActiveRecord::Base.each and ActiveRecord::Base.find_in_batches for batch processing [DHH/Jamis Buck] 2009-02-23 12:11:02 +01:00