Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | Make #increment! and #decrement! methods concurency safe | Bogdan Gusiev | 2015-10-05 | 1 | -27/+19 |
| | |||||
* | raise ActiveModel::MissingAttributeError when trying to access a ↵ | Diego Carrion | 2015-06-16 | 1 | -1/+1 |
| | | | | | | | | relationship without the foreign key attribute fixes regression reported on #20253 ActiveRecord::Base#[] was not used cause of 8b95420 | ||||
* | Improve consistency of counter caches updating in memory | Sean Griffin | 2015-01-26 | 1 | -0/+3 |
| | | | | | | | | | | | | | | | | | When we made sure that the counter gets updated in memory, we only did it on the has many side. The has many side only does the update if the belongs to cannot. The belongs to side was updated to update the counter cache (if it is able). This means that we need to check if the belongs_to is able to update in memory on the has_many side. We also found an inconsistency where the reflection names were used to grab the association which should update the counter cache. Since reflection names are now strings, this means it was using a different instance than the one which would have the inverse instance set. Fixes #18689 [Sean Griffin & anthonynavarre] | ||||
* | Improve the performance of reading belongs_to associations | Sean Griffin | 2014-12-22 | 1 | -5/+6 |
| | | | | | | | | | | | | `ActiveRecord::Base#[]` has overhead that was introduced in 4.2. The `foo["id"]` working with PKs other than ID isn't really a case that we want to support publicly, but deprecating was painful enough that we avoid it. `_read_attribute` was introduced as the faster alternative for use internally. By using that, we can save a lot of overhead. We also save some overhead by reading the attribute one fewer times in `stale_state`. Fixes #18151 | ||||
* | add has_one? method and reuse instead of checking macro | eileencodes | 2014-06-09 | 1 | -1/+1 |
| | | | | | | Instead of checking for `macro == :has_one` throughout the codebase we can create a `has_one?` method to match the `belongs_to?`, `polymorphic?` and other methods. | ||||
* | Hide BelongsToAssociation#increment_counters and #decrement_counters | Jean Boussier | 2014-04-15 | 1 | -2/+2 |
| | |||||
* | Use inheritance chain instead of callbacks to increment counter caches after ↵ | Jean Boussier | 2014-04-14 | 1 | -4/+14 |
| | | | | create | ||||
* | extract cache counter logic to one method | Aaron Patterson | 2013-12-12 | 1 | -11/+10 |
| | |||||
* | remove duplicate code | Aaron Patterson | 2013-12-12 | 1 | -15/+6 |
| | |||||
* | extract a method for updating without a record object | Aaron Patterson | 2013-12-12 | 1 | -6/+10 |
| | |||||
* | extract methods out of the cache update method | Aaron Patterson | 2013-12-12 | 1 | -14/+22 |
| | |||||
* | pull a nil check up one frame | Aaron Patterson | 2013-12-12 | 1 | -6/+10 |
| | |||||
* | remove more nil checks | Aaron Patterson | 2013-12-12 | 1 | -6/+5 |
| | |||||
* | remove nil check | Aaron Patterson | 2013-12-12 | 1 | -6/+10 |
| | | | | | calling replace_keys could possibly do a nil check twice, this commit reduces it to once. | ||||
* | remove the nil check from set_inverse_instance | Aaron Patterson | 2013-12-12 | 1 | -1/+1 |
| | | | | | methods that call set_inverse_instance with a record will not have to pay the cost of a nil check on every call | ||||
* | Remove useless comment and white spaces :scissors: [ci skip] | Carlos Antonio da Silva | 2013-09-01 | 1 | -2/+2 |
| | |||||
* | Adding a bang to method name of raise_on_type_mismatch. | wangjohn | 2013-03-21 | 1 | -1/+1 |
| | |||||
* | BELONGS TO ASSOCIATION | Typo fix | libin | 2013-02-25 | 1 | -1/+1 |
| | |||||
* | improved different_target conditions | Angelo Capilleri | 2013-01-08 | 1 | -2/+5 |
| | |||||
* | move dependency logic out of generated methods | Jon Leighton | 2012-08-10 | 1 | -0/+5 |
| | |||||
* | @stale_state should be nil when a model isn't saved. | kennyj | 2012-04-13 | 1 | -1/+1 |
| | |||||
* | Some refactor for association. | kennyj | 2012-04-12 | 1 | -0/+5 |
| | | | | | | | * Remove unused association_class method. * Remove a unnecessary assignment. * Move @updated to BelongsToAssociation that only reference this instance variable. * Reset @stale_state at the reset method. I think this place is right place. | ||||
* | Fix belongs_to polymorphic with custom primary key on target. | Jon Leighton | 2011-09-26 | 1 | -1/+5 |
| | | | | Closes #3104. | ||||
* | Don't find belongs_to target when the foreign_key is NULL. Fixes #2828 | Georg Friedrich | 2011-09-05 | 1 | -0/+4 |
| | |||||
* | Fix exception if old and new targets are both nil. Fixes #1471. | Jon Leighton | 2011-07-12 | 1 | -1/+1 |
| | |||||
* | Rename target_klass to klass | Jon Leighton | 2011-02-21 | 1 | -1/+1 |
| | |||||
* | Delegate Association#options to the reflection, and replace ↵ | Jon Leighton | 2011-02-21 | 1 | -1/+1 |
| | | | | 'reflection.options' with 'options'. Also add through_options and source_options methods for through associations. | ||||
* | Singular associations no longer use a proxy, so no need to check for the ↵ | Jon Leighton | 2011-02-21 | 1 | -1/+1 |
| | | | | proxy type on assignment. | ||||
* | Associations - where possible, call attributes methods rather than directly ↵ | Jon Leighton | 2011-02-21 | 1 | -10/+10 |
| | | | | accessing the instance variables | ||||
* | Let's be less blasé about method visibility on association proxies | Jon Leighton | 2011-01-30 | 1 | -0/+1 |
| | |||||
* | find_target can also go into SingularAssociation | Jon Leighton | 2011-01-16 | 1 | -4/+0 |
| | |||||
* | Abstract a bit more into SingularAssociation | Jon Leighton | 2011-01-16 | 1 | -2/+1 |
| | |||||
* | Use self.target= rather than @target= as the former automatically sets loaded | Jon Leighton | 2011-01-16 | 1 | -3/+1 |
| | |||||
* | Abstract common code from BelongsToAssociation and HasOneAssociation into ↵ | Jon Leighton | 2011-01-16 | 1 | -19/+1 |
| | | | | SingularAssociation | ||||
* | belongs_to records should be initialized within the association scope | Jon Leighton | 2011-01-16 | 1 | -2/+8 |
| | |||||
* | Add create_association! for belongs_to | Jon Leighton | 2011-01-16 | 1 | -0/+4 |
| | |||||
* | reduce funcalls by using falsey objects | Aaron Patterson | 2011-01-14 | 1 | -2/+2 |
| | |||||
* | Construct an actual ActiveRecord::Relation object for the association scope, ↵ | Jon Leighton | 2011-01-07 | 1 | -17/+0 |
| | | | | rather than a hash which is passed to apply_finder_options. This allows more flexibility in how the scope is created, for example because scope.where(a, b) and scope.where(a).where(b) mean different things. | ||||
* | When preloading a belongs_to, the target should still be set (to nil) if ↵ | Jon Leighton | 2011-01-03 | 1 | -3/+1 |
| | | | | there is no foreign key present. And the loaded flag should be set on the association proxy. This then allows us to remove the foreign_key_present? check from BelongsToAssociation#find_target. Also added a test for the same thing on polymorphic associations. | ||||
* | Create the association scope directly rather than going through with_scope | Jon Leighton | 2011-01-03 | 1 | -1/+1 |
| | |||||
* | Rename AssociationProxy#foreign_key_present to foreign_key_present? | Jon Leighton | 2011-01-03 | 1 | -3/+3 |
| | |||||
* | Allow assignment on has_one :through where the owner is a new record [#5137 ↵ | Jon Leighton | 2011-01-03 | 1 | -11/+4 |
| | | | | | | | | | | state:resolved] This required changing the code to keep the association proxy for a belongs_to around, despite its target being nil. Which in turn required various changes to the way that stale target checking is handled, in order to support various edge cases (loaded target is nil then foreign key added, foreign key is changed and then changed back, etc). A side effect is that the code is nicer and more succinct. Note that I am removing test_no_unexpected_aliasing since that is basically checking that the proxy for a belongs_to *does* change, which is the exact opposite of the intention of this commit. Also adding various tests for various edge cases and related things. Phew, long commit message! | ||||
* | Rename AssociationReflection#primary_key_name to foreign_key, since the ↵ | Jon Leighton | 2010-12-31 | 1 | -7/+7 |
| | | | | options key which it relates to is :foreign_key | ||||
* | Support for :counter_cache on polymorphic belongs_to | Jon Leighton | 2010-12-31 | 1 | -1/+1 |
| | |||||
* | Refactor BelongsToAssociation to allow BelongsToPolymorphicAssociation to ↵ | Jon Leighton | 2010-12-31 | 1 | -49/+55 |
| | | | | inherit from it | ||||
* | Refactor we_can_set_the_inverse_on_this? to use a less bizarre name amongst ↵ | Jon Leighton | 2010-12-26 | 1 | -4/+5 |
| | | | | other things | ||||
* | If a has_many goes :through a belongs_to, and the foreign key of the ↵ | Jon Leighton | 2010-12-23 | 1 | -1/+4 |
| | | | | belongs_to changes, then the has_many should be considered stale. | ||||
* | Improved strategy for updating a belongs_to association when the foreign key ↵ | Jon Leighton | 2010-12-23 | 1 | -0/+8 |
| | | | | 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. | ||||
* | removing space error | Aaron Patterson | 2010-11-22 | 1 | -1/+1 |
| | |||||
* | use persisted? instead of new_record? wherever possible | David Chelimsky | 2010-11-09 | 1 | -3/+3 |
| | | | | | | | | | | | - 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> |