Santiago Pastorino
304d38c053
Allow primary_key to be an attribute when the model is a new record
2010-12-28 10:11:27 -02:00
Aaron Patterson
7e91ad3f89
stop calling deprecated apis
2010-12-26 19:56:18 -07:00
Jon Leighton
e8ada11aac
Associations: DRY up the code which is generating conditions, and make it all use arel rather than SQL strings
2010-12-26 19:38:04 +00:00
Jon Leighton
f2230c06ed
Fix dodgy tests which were effectively asserting nil == nil
2010-12-26 19:38:04 +00:00
Aaron Patterson
5b918bb97c
using arel to compile sql statements
2010-12-25 16:19:59 -07:00
Aaron Patterson
a6fe244e9b
take more advantage of arel sql compiler
2010-12-25 15:23:45 -07:00
Aaron Patterson
ec13305b21
stop redifining methods on every call to set_primary_key
2010-12-24 22:15:41 -07:00
oleg dashevskii
6974c595fd
Verify that there is no unwanted implicit readonly set on Model.has_many_through.find(id) [ #5442 state:resolved]
2010-12-23 15:19:18 -08:00
Jon Leighton
fb3a8c51b4
Raise an error for associations which try to go :through a polymorphic association [ #6212 state:resolved]
2010-12-23 15:19:18 -08:00
Jon Leighton
1c07b84df9
If a has_many goes :through a belongs_to, and the foreign key of the belongs_to changes, then the has_many should be considered stale.
2010-12-23 15:19:18 -08:00
Jon Leighton
2d9626fc74
Improved strategy for updating a belongs_to association when the foreign key changes. Rather than resetting each affected association when the foreign key changes, we should lazily check for 'staleness' (where fk does not match target id) when the association is accessed.
2010-12-23 15:19:18 -08:00
Jon Leighton
3f17ed407c
Test to verify that #2189 (count with has_many :through and a named_scope) is fixed
2010-12-23 15:19:18 -08:00
Jon Leighton
1619c2435b
Revert "Optimize <association>_ids for hm:t with belongs_to source". The optimisation has too many edge cases, such as when the reflection, source reflection, or through reflection has conditions, orders, etc. [ #6153 state:resolved]
...
This reverts commit 373b053dc8 .
Conflicts:
activerecord/lib/active_record/associations.rb
2010-12-23 15:19:18 -08:00
Jon Leighton
4e13625818
Test demonstrating problem with foo.association_ids where it's a has_many :through with :conditions, with a belongs_to as the source reflection
2010-12-23 15:19:18 -08:00
Jon Leighton
ff7bde62c8
When a has_many association is not :uniq, appending the same record multiple times should append it to the @target multiple times [ #5964 state:resolved]
2010-12-23 15:19:17 -08:00
Michał Łomnicki
030480ac1f
Fix behaviour of foo.has_many_through_association.select('custom select') [ #6089 state:resolved]
2010-12-23 15:19:17 -08:00
Szymon Nowak
85683f2a79
Fix creation of has_many through records with custom primary_key option on belongs_to [ #2990 state:resolved]
2010-12-23 15:19:17 -08:00
Will Bryant
b79823832e
Verify that has_one :through preload respects the :conditions [ #2976 state:resolved]
2010-12-23 15:19:17 -08:00
Jon Leighton
c6db37e69b
Don't allow a has_one association to go :through a collection association [ #2976 state:resolved]
2010-12-23 15:19:17 -08:00
Raimonds Simanovskis
d9c8c47e3d
Fix for default_scope tests to ensure comparing of equally sorted lists
...
This is additional fix for commit
ebc47465a5 Respect the default_scope on a join model when reading a through association
which otherwise was failing on Oracle (as it returned fixture comments in different order).
2010-12-23 23:19:59 +08:00
Aaron Patterson
3e64336647
removing SQL interpolation, please use scoping and attribute conditionals as a replacement
2010-12-22 18:23:38 -08:00
Aaron Patterson
207f266cca
define_attr_method must serialize nil correctly
2010-12-20 19:47:15 -08:00
Aaron Patterson
099a210c83
if there is no base name, we cannot determine a primary key
2010-12-20 19:47:15 -08:00
Jon Leighton
834e5336a5
has_many associations with :dependent => :delete_all should update the counter cache when deleting records
2010-12-20 13:56:04 -08:00
Jon Leighton
b8153fd5a1
Fix problem where wrong keys are used in JoinAssociation when an association goes :through a belongs_to [ #2801 state:resolved]
2010-12-20 13:56:04 -08:00
Piotr Sarnacki
40b15f9f38
ActiveRecord::Base.joins should allow single nil argument [ #6181 state:resolved]
2010-12-16 22:25:09 +01:00
Jon Leighton
14b880fd03
Fix various issues with the :primary_key option in :through associations [ #2421 state:resolved]
2010-12-15 17:50:14 -08:00
Jon Leighton
09ddca67ac
Fix problem with duplicated records when a :uniq :through association is preloaded [ #2447 state:resolved]
2010-12-15 17:47:42 -08:00
Pavel Gorbokon
96bae30538
Replace rudimentary named_scope with scope. [ #6052 state:resolved]
...
* rename method names (actually in tests)
* rename instance variable @_named_scopes_cache to @_scopes_cache
* rename references in doc comments
* don't touch CHANGELOG :)
2010-12-15 14:02:30 -08:00
Franck Verrot
aa40543022
Provide test for #4840 : to_xml doesn't work in such case: Event.select('title as t').to_xml
2010-12-15 14:02:30 -08:00
Pivotal Labs
15984dbe35
test for eager load of has_one association with condition on the through table
2010-12-16 01:49:30 +05:30
Jon Leighton
491ce5b6ce
Verify that creating a has_many through record where there is a default_scope on the join model works correctly (creates the join record with the default scope applied)
2010-12-16 01:49:30 +05:30
Jon Leighton
eba7664086
Respect the default_scope on a join model when reading a through association
2010-12-16 01:49:30 +05:30
Ernie Miller
5d37ff6bb2
Fix hm:t to self table aliasing in construct_scope
2010-12-16 01:49:29 +05:30
Joe Hannon
7bffa9dd01
add test which fails for has_many through self join [ #4361 state:open]
2010-12-16 01:49:29 +05:30
Aaron Patterson
08ccca7644
fixing whitespace errors
2010-12-16 01:49:29 +05:30
Aaron Patterson
a1ca1e85a9
persisted? should be able to return a truthy object
2010-12-16 01:49:28 +05:30
Chiel Wester
bda16eb092
Only call save on belongs_to associations if the record has changed or any nested associations have changed ( resolves #3353 )
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-12-16 01:49:28 +05:30
Aaron Patterson
3e7c351b48
preheating cache so that tests can run in isolation
2010-12-09 15:12:48 -08:00
Robert Pankowecki (Gavdi)
bba3dacc3d
Simplifies observer implementation [ #6065 state:resolved]
2010-12-09 10:41:43 -08:00
Piotr Sarnacki
6f8958277b
Fix test on finding migrations from 2 paths
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-12-09 18:50:44 +01:00
José Valim
cc48192248
Merge remote branch 'drogus/dummy_tasks'
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-12-09 16:09:51 +01:00
Mike Dvorkin
f572a02b94
Take into account current time zone when serializing datetime values [ #6096 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-12-09 09:01:49 +01:00
Aditya Sanghi
7a237d56aa
Ensure that boolean false is properly serialized [ #6079 state:resolved]
2010-12-08 15:51:47 -08:00
Jeff Dean
7ecee054a3
Setting the id of a belongs_to object updates all referenced objects [ #2989 state:resolved]
2010-12-08 15:21:18 -08:00
Piotr Sarnacki
d0467e08e5
Allow to run migrations from more than one directory
2010-12-09 00:04:36 +01:00
Aaron Patterson
a299fcaef9
not a responsibility for rails to test
2010-12-03 16:22:42 -08:00
Aaron Patterson
399730bdd2
removing unused setup
2010-12-03 12:00:09 -08:00
Aaron Patterson
47737681fd
in the middle of refactoring
2010-12-03 12:00:09 -08:00
Santiago Pastorino
42c51b8527
Doesn't need to sort, lets users of attribute_names sort them if they want
2010-12-02 20:28:24 -02:00