Pratik Naik
9f4e98330b
Remove unused construct_finder_sql
2009-12-28 12:57:35 +05:30
Pratik Naik
1c26ba486c
Add Model.from and association_collection#from finder methods
2009-12-28 03:59:44 +05:30
Pratik Naik
630dc50730
Fix relation tests for postgres
2009-12-28 02:50:04 +05:30
Pratik Naik
51a1d5a670
Handle preloads and eager loads when merging relations
2009-12-28 01:33:20 +05:30
Pratik Naik
a8b10a2a8d
Add relation#merge to merge two relations
2009-12-28 01:08:34 +05:30
Pratik Naik
bbdeaae2ca
Add relation.destroy_all
2009-12-27 21:15:12 +05:30
Pratik Naik
d5e98dc859
Add relation.last and relation.reverse_order
2009-12-27 19:04:30 +05:30
Pratik Naik
2c8f83556b
Add relation.exists?
2009-12-27 18:00:49 +05:30
Pratik Naik
d92c4a8402
Add find(ids) to relations
2009-12-27 16:15:29 +05:30
Pratik Naik
81608cf8fa
Make Model.all return an array rather than a relation for consistency. Use Model.scoped to get a relation
2009-12-27 15:06:45 +05:30
Pratik Naik
85770ec713
Make Model.find_or_create_by_* and find_or_initialize_by_* use relations and remove method caching
2009-12-27 14:46:38 +05:30
Pratik Naik
d511de0261
Add find_or_create_by_* and find_or_initialize_by_* to relations
2009-12-27 14:28:19 +05:30
Pratik Naik
8829d6ecc6
Make Model.find_by_* and Model.find_all_by_* use relations and remove dynamic method caching
2009-12-27 13:17:29 +05:30
Pratik Naik
f6f416c58e
Add find_by_* and find_all_by_* finders to ActiveRecord::Relation
2009-12-27 03:25:29 +05:30
Pratik Naik
cc753eaf58
Replace Model.first(options) with new finder methods inside tests
2009-12-27 01:50:03 +05:30
Pratik Naik
83f24afd44
Add new finder methods to association collection.
2009-12-27 00:25:00 +05:30
Pratik Naik
f374150698
Ensure Model.scoped adds type conditions for STI models
2009-12-27 00:11:31 +05:30
Pratik Naik
c6258ee313
Ensure all the finder methods respect scoping
2009-12-26 19:15:05 +05:30
Pratik Naik
9a9f97af28
Add relation.reload to force reloading the records
2009-12-26 15:31:50 +05:30
Pratik Naik
3c5a7dcaf5
Cache the loaded relations
2009-12-26 15:07:00 +05:30
Pratik Naik
9d3d60c64a
Ensure preload and eager_load finder methods accept multiple arguments
2009-12-26 14:40:45 +05:30
Pratik Naik
187fbe5cba
Add support for multiple arguments to .where finder
2009-12-26 12:57:34 +05:30
Pratik Naik
feb8b20eb5
Add Relation#all as an alias for to_a
2009-12-26 12:39:44 +05:30
Pratik Naik
95274b28d9
Rename Model.conditions and relation.conditions to .where
2009-12-26 03:50:57 +05:30
Pratik Naik
1a99337180
No parentheses for assert_equal
2009-12-26 03:10:55 +05:30
Pratik Naik
a7fd564ab1
Add Model.select/group/order/limit/joins/conditions/preload/eager_load class methods returning a lazy relation.
...
Examples :
posts = Post.select('id).order('name') # Returns a lazy relation
posts.each {|p| puts p.id } # Fires "select id from posts order by name"
2009-12-26 03:06:51 +05:30
Pratik Naik
2e79ec71a5
Model.scoped now returns a relation if invoked without any arguments
...
Example :
posts = Post.scoped
posts.size # Fires "select count(*) from posts" and returns the count
posts.each {|p| puts p.name } # Fires "select * from posts" and loads post objects
2009-12-26 01:33:20 +05:30
Joshua Peek
7ee5843c3c
Fully expand relative rails framework paths and make sure we aren't
...
adding any to the load path more than once.
2009-12-16 11:56:51 -06:00
Will
bf6af5f719
When passing force_reload = true to an association, don't use the query cache [ #1827 state:resolved]
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-12-16 10:49:53 -06:00
Serguei Filimonov
2ae8300489
Added #to_i to DateTime in ActiveSupport so #to_yaml works correctly on ActiveRecord models with DateTime attributes.
2009-12-15 08:15:21 -06:00
Joshua Peek
25bb301d9c
Forgot to revert tests from that last commit
2009-12-12 21:03:45 -06:00
Joshua Peek
8a50f8a545
Revert "Fix instance_eval calls to association proxies"
...
I think it may of broke the build. Lets see.
This reverts commit 49e943c4f0 .
Conflicts:
activerecord/test/cases/associations/has_many_associations_test.rb
2009-12-12 19:58:54 -06:00
John Pignata
96deabace7
Fix postgresql AR test failure
...
Due to the ordering of the returning result set, the test fails under the postgresql adapter. Order results by id prior to checking the first item
[#3542 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-12-11 15:15:12 -06:00
Gabe da Silveira
32395899d7
Replace reset_counter_cache with reset_counters that has API inline with existing update_counters method
...
[#1211 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-12-03 23:25:11 -08:00
Ben Marini
e55284e825
Add support for Mysql column positioning via #add_column and #change_column
...
add_column and change_column in the Mysql adapter now accept some
additional options:
:first => true # Put the column in front of all the columns
:after => column_name # Put the colmn after 'column_name'
add_column :new_col, :string, :first => true
add_column :another_col, :integer, :default => 0, :after => :new_col
[#3286 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-12-03 23:09:57 -08:00
Mat Brown
49e943c4f0
Fix instance_eval calls to association proxies
...
In the current stable, ActiveRecord::Associations::AssociationProxy#method_missing calls yield() if a block is given, causing the block to always be evaluated in its calling context. However, in the case of instance_eval, correct behavior requires that the block be passed directly to the @target, rather than being evaluated inside a different block. Incidentally, this also simplifies the code slightly.
[#3412 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-12-02 12:47:09 -08:00
Mike Breen
50c28e78c7
Implement ActiveRecord#reset_counter_cache
...
[#1211 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-12-02 12:20:00 -08:00
Jeremy Kemper
78790e47b8
Revert "Revert "Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted.""
...
This reverts commit 2b82708b0e .
[#3128 state:resolved]
Conflicts:
activerecord/lib/active_record/associations.rb
activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
2009-11-23 10:42:32 -08:00
Gabe da Silveira
ea290e77e6
Insert generated association members in the same order they are specified when assigning to a has_many :through using the generated *_ids method
...
[#3491 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-11-17 22:25:40 -08:00
Jeremy Kemper
fb61fbd352
Revert "Ensure Model#destroy respects optimistic locking"
...
[#1966 state:open]
This reverts commit 0d922885fb .
Conflicts:
activerecord/lib/active_record/locking/optimistic.rb
2009-11-17 15:35:35 -08:00
Jeremy Kemper
7601d482bd
Ruby 1.9: skip pg locking test for 1.9.1 also
2009-11-15 10:28:58 -08:00
Jeremy Kemper
f0f4dffd3b
Skip pg locking test due to connection checkout deadlock detection
2009-11-14 01:22:36 -08:00
Jeremy Kemper
0da71980cd
Missing customers fixture
2009-11-13 10:38:23 -08:00
Jeremy Kemper
77478f21af
Resolve deadlock in pooled connections test
2009-11-10 11:00:29 -08:00
Matt Jones
d625312fe1
delete correct records for a has_many with :primary_key and :dependent => :delete_all
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
2009-11-10 18:41:37 +13:00
Joshua Peek
11e798ae0f
Avoid adding component lib/ to load path multiple times
2009-11-09 23:28:36 -06:00
Jeremy Kemper
703d31c20a
Clarify failed assertion
2009-11-09 17:01:57 -08:00
Eloy Duran
f125a34501
Define autosave association callbacks when using accepts_nested_attributes_for.
...
This way we don't define all the validation methods for all associations by
default, but only when needed.
[#3355 state:resolved]
2009-11-07 00:42:42 +01:00
José Valim
e714b499cc
Move validator, human_name and human_attribute_name to ActiveModel, remove deprecated error messages and add i18n_scope and lookup_ancestors.
...
Signed-off-by: Carl Lerche <carllerche@mac.com >
2009-10-20 17:52:32 -07:00
Yehuda Katz + Carl Lerche
4f6d6f7031
Have all the tests running off a single Gemfile
2009-10-20 16:34:44 -07:00