Commit Graph

189 Commits

Author SHA1 Message Date
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
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
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
Aaron Patterson
542cb5c327 fix warnings, stop using global variables 2010-11-30 18:46:56 -08:00
Neeraj Singh
66212f69ac If a nested_attribute is being marked for destruction and at the same time an attr_accessor value is being assigned then the value being assigned is being ignored. This patch is a fix for that issue.
[#5939 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-24 22:08:36 +01:00
David Chelimsky
1f06652a57 use persisted? instead of new_record? wherever possible
- persisted? is the API defined in ActiveModel
- makes it easier for extension libraries to conform to ActiveModel APIs
  without concern for whether the extended object is specifically
  ActiveRecord

[#5927 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-09 13:54:04 -02:00
Denis Odorcic
cc9742920c Convert :primary_key in association to a string before comparing to column names, so that for example :primary_key => :another_pk works as well [#5605 state:resolved] 2010-10-30 11:24:36 -07:00
Xavier Noria
5b86c3e5bb has_one maintains the association with separate after_create/after_update
This way parent models can get their own after_create and
after_update callbacks fired after has_one has done its job.
2010-10-22 10:28:53 +02:00
Aaron Patterson
d2898d4ef8 scopes can take an object that responds to call 2010-10-19 17:29:25 -07:00
Tim Morgan
b1b26af9a2 Allow default_scope to accept a Proc. 2010-10-19 14:43:31 -07:00
Jon Leighton
076b75bf98 Add some tests for functionality in JoinAssociation which already exists but was previously untested 2010-10-13 08:24:19 -07:00
Santiago Pastorino
e0b76d6151 reorder removed in favor of except(:order).order 2010-10-11 11:54:46 -02:00
Neeraj Singh
9401fa0b9c expanding the test to include both type of order declaration
while declaring default_scope

Also added test for unscoped using block style with four different
combinations

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-18 20:49:19 +02:00
Raimonds Simanovskis
af2a011df2 fixed Subject model after_initialize callback for test_oracle_synonym test 2010-09-09 18:27:53 -07:00
Nick Ragaz
16e078d908 failing test for reorder overriding default_scope
[5528]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-05 08:27:51 -03:00
Neeraj Singh
91fec0d24d order should always be concatenated.
order that is declared first has highest priority in all cases.

Here are some examples.

Car.order('name desc').find(:first, :order => 'id').name

Car.named_scope_with_order.named_scope_with_another_order

Car.order('id DESC').scoping do
  Car.find(:first, :order => 'id asc')
end

No special treatment to with_scope or scoping.

Also note that if default_scope declares an order then the order
declared in default_scope has the highest priority unless
with_exclusive_scope is used.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-05 08:13:42 -03:00
Pratik Naik
c07f0ae52e Change relation merging to always append select, group and order values 2010-08-31 19:17:18 +01:00
Neeraj Singh
2e45542942 While creating a new record using has_many create method default scope of child should be respected.
author.posts.create should take into account default_scope
defined on post.

[#3939: state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-19 14:52:15 -03:00
Santiago Pastorino
9a7e7e5fdb Add missing model 2010-08-14 18:49:04 -03:00
Santiago Pastorino
b451de0d6d Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 04:12:33 -03:00
Neeraj Singh
6ed1ba472e Ensure we can nest include calls [#5285 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-12 13:10:58 -03:00
Neeraj Singh
009aa8825b Eager loading an association should not change the count of children
[#4971 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-02 17:12:59 +02:00
Robert Pankowecki
f8b53f35b9 test and fix collection_singular_ids= with string primary keys [#5125 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-02 16:41:20 +02:00
Santiago Pastorino
b0b9bf3204 Object#returning removed
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-25 23:30:27 +02:00
José Valim
7131244313 Ensure default_scope can be overwriten by association conditions. 2010-07-21 15:06:23 +02:00
Subba Rao Pasupuleti
d77c3b669c eagerly loaded association records should respect default_scope [#2931 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-21 15:01:40 +02:00
Neeraj Singh
992711a86b update_attribute should not update readonly attributes
[#5106 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-21 14:55:57 +02:00
Neeraj Singh
f576d7cf84 Ensure that primary_keys of HABTM records is not double quoted
[#5152 state:reslved]
2010-07-20 16:45:42 -07:00
Neeraj Singh
f4fbc2c1f9 update_attributes and update_attributes! are now wrapped in a transaction
[#922 state:resovled]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-13 22:02:00 +02:00
Vitalii Khustochka
b75fca9e57 Added reorder delegation for ActiveRecord::Base(to be able to overwrite the default_scope ordering in the named scope [#5093 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-13 08:31:55 +02:00
Will St. Clair + Neeraj Singh
b520d602ff string IDs are now quoted correctly [#5064 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-13 08:14:52 +02:00
Neeraj Singh
1e53404fe9 reset_counter should work with non-traditional belongs_to and polymorphic belongs_to
[#4984 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 23:24:12 +02:00
Grant Ammons
17650e394f Eager loading :through associations will join the :source model if there are :conditions. [#2362 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 22:36:26 +02:00
Josh Kalderimis
4b66aab00f mass_assignment_security moved from AR to AMo, and minor test cleanup
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 18:28:45 +02:00
Josh Kalderimis
7c86e8e21b minor changes to mass assignment security patch to bring it in line with rails standards
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 18:28:38 +02:00
Ben Somers
de51cbccf8 Fixed gruoped_by_title spelling [#5063 state:committed]
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-07-08 00:26:25 +02:00
José Valim
67582f08bf Push a failing test for issues [#4994] and [#5003]. 2010-06-29 19:50:09 +02:00
Neeraj Singh
40e87ac669 with_exclusive_scope does not work properly if ARel is passed. It does work nicely if hash is passed. Blow up if user is attempting it pass ARel to with_exclusive_scope.
[#3838 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-29 01:18:20 +02:00
James Le Cuirot
f664c57fe8 Don't overwrite unsaved updates when loading an association but preserve the order of the loaded records. Reapplied from before but now allows already-saved records to be refreshed.
[#4830 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-20 00:32:06 +02:00
José Valim
85cc1fa657 Revert "Don't overwrite unsaved updates when loading an association but preserve the order of the loaded records. [#4642 state:open]"
This commit introduced a regression described in ticket [#4830].

This reverts commit 0265c708b9.
2010-06-11 17:05:54 +02:00
James Le Cuirot
0265c708b9 Don't overwrite unsaved updates when loading an association but preserve the order of the loaded records. [#4642 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2010-06-09 18:17:52 +05:30
Raimonds Simanovskis
8136230cca Explicitly set Topic model last_read attribute as Date value when Oracle enhanced adapter is used
(otherwise some tests are failing which assume that this attribute will have Date value)
2010-06-04 22:44:02 +03:00
Pratik Naik
517f709b51 Properly cache association_collection#scopes calls having arguments 2010-06-04 00:53:45 +01:00
José Valim
ad4be3d75d Fix failing test. 2010-05-21 16:20:56 +02:00
Ian White
b439d85a19 Nested records (re: autosave) are now updated even when the intermediate parent record is unchanged [#4242 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-18 16:13:00 +02:00
Diego Algorta
3436fdfc12 Fix for get_ids when including a belongs_to association on a has_many association [#2896 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2010-05-15 16:53:59 +01:00
José Valim
5c245b91d2 Make sure valid? preceives the context as in ActiveModel API (ht: Carlos Antonio) 2010-05-10 12:28:38 +03:00