Commit Graph

31 Commits

Author SHA1 Message Date
Alexander Balashov
4a4a566b12 In batches test @total was assigned but not used. Use it in tests instead of Post.count 2013-05-21 12:26:13 +04:00
Prathamesh Sonpatki
6943497dff Fixed typos in ActiveRecord 2013-03-28 20:25:43 +05:30
Alexander Balashov
cfe92c8fd7 Fix typo 2013-03-28 17:45:24 +04:00
Vipul A M
55686dd1be fix typos in AR. lots of them. 2013-03-19 00:04:39 +05:30
Carlos Antonio da Silva
9fdf606954 Remove extre count, preheat already happens during setup 2012-10-31 12:54:07 -02:00
Alexis Bernard
a58cafeb3a Fix find_in_batches against string IDs when start option is not specified. 2012-10-31 15:39:24 +01:00
Santiago Pastorino
19fa8fa3c4 Fix test_find_in_batches_should_use_any_column_as_primary_key 2012-09-22 10:57:54 -03:00
Santiago Pastorino
5b99cf088c start could be a string
Related to 761bc751d31c22e2c2fdae2b4cdd435b68b6d783 and
eb876c4d07130f15be2cac7be968cc393f959c62
2012-09-21 19:42:16 -03:00
Santiago Pastorino
eb876c4d07 Revert "Fix find_in_batches with customized primary_key"
This reverts commit 761bc751d31c22e2c2fdae2b4cdd435b68b6d783.

This commit wasn't fixing any issue just using the same table for
different models with different primary keys.
2012-09-21 19:14:17 -03:00
Toshiyuki Kawanishi
761bc751d3 Fix find_in_batches with customized primary_key 2012-09-16 20:02:23 +09:00
Jon Leighton
55b24888bb Remove ActiveRecord::Base.to_a
On reflection, it seems like a bit of a weird method to have on
ActiveRecord::Base, and it shouldn't be needed most of the time anyway.
2012-08-03 11:51:52 +01:00
Jon Leighton
6a81ccd69d ActiveRecord::Base.all returns a Relation.
Previously it returned an Array.

If you want an array, call e.g. `Post.to_a` rather than `Post.all`. This
is more explicit.

In most cases this should not break existing code, since
Relations use method_missing to delegate unknown methods to #to_a
anyway.
2012-07-27 13:34:12 +01:00
Jon Leighton
f6ddb13113 remove deprecated #find_in_batches calls 2012-04-26 18:04:41 +01:00
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