aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Merge pull request #11416 from tigrish/master"Yves Senn2013-07-222-2/+2
| | | | | This reverts commit 9dc8aef084fc5ae7e3a396dd098d89da93d06fda, reversing changes made to 02e8dae6279ea25312293a3eca777faf35139c4c.
* Merge pull request #11416 from tigrish/masterYves Senn2013-07-212-2/+2
|\ | | | | Rename the I18n keys for associations' restrict_dependent_destroy errors
| * Remove ambiguity with pluralizations and I18n keys used for association ↵Christopher Dell2013-07-132-2/+2
| | | | | | | | restrict_dependent_destroy errors
* | use the superclass implementationAaron Patterson2013-07-181-1/+1
| |
* | parent_table is only used internallyAaron Patterson2013-07-161-4/+4
| |
* | decouple the manager class from building join constraintsAaron Patterson2013-07-161-6/+6
| |
* | cache the klass member of the reflectionAaron Patterson2013-07-161-8/+10
| |
* | cache the scope chain on the stack and eliminate `i`Aaron Patterson2013-07-161-7/+4
| |
* | just push on to the scope chain items. Oops! (thanks @carlosantoniodasilva)Aaron Patterson2013-07-161-2/+1
| |
* | use Relation#merge to combine scope chain itemsAaron Patterson2013-07-161-6/+6
| |
* | make sure scope_chain_items has consistent typesAaron Patterson2013-07-161-7/+9
|/
* #11288: Removed duplicated touchingPaul Nikitochkin2013-07-051-1/+1
| | | | | | if belongs to model with touch option on touch Closes #11288
* Dropped deprecated option `:restrict` for `:dependent` in associationsNeeraj Singh2013-07-035-11/+4
|
* Removed support for deprecated `delete_sql` in associations.Neeraj Singh2013-07-032-16/+11
|
* Removed support for deprecated `insert_sql` in associations.Neeraj Singh2013-07-022-10/+6
|
* fix indentationNeeraj Singh2013-07-021-14/+14
|
* Removed support for deprecated `finder_sql` in associations.Neeraj Singh2013-07-023-41/+6
|
* Removed support for deprecated `counter_sql`Neeraj Singh2013-07-024-18/+14
|
* Merge pull request #10604 from ↵Rafael Mendonça França2013-07-012-15/+31
|\ | | | | | | | | | | | | | | | | neerajdotname/delete_all_should_not_call_callbacks Do not invoke callbacks when delete_all is called Conflicts: activerecord/CHANGELOG.md
| * Do not invoke callbacks when delete_all is calledNeeraj Singh2013-06-302-15/+31
| | | | | | | | | | | | | | | | | | | | | | Method `delete_all` should not be invoking callbacks and this feature was deprecated in Rails 4.0. This is being removed. `delete_all` will continue to honor the `:dependent` option. However if `:dependent` value is `:destroy` then the default deletion strategy for that collection will be applied. User can also force a deletion strategy by passing parameter to `delete_all`. For example you can do `@post.comments.delete_all(:nullify)`
* | Removed deprecated options for assocationsNeeraj Singh2013-07-022-19/+0
| | | | | | | | | | Deprecated options `delete_sql`, `insert_sql`, `finder_sql` and `counter_sql` have been deleted.
* | Removed deprecated method scopedNeeraj Singh2013-07-011-5/+0
| |
* | don't shadow `through_scope` method name with local var.Yves Senn2013-06-301-7/+7
|/
* Simplify/fix implementation of default scopesJon Leighton2013-06-284-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation was necessary in order to support stuff like: class Post < ActiveRecord::Base default_scope where(published: true) scope :ordered, order("created_at") end If we didn't evaluate the default scope at the last possible moment before sending the SQL to the database, it would become impossible to do: Post.unscoped.ordered This is because the default scope would already be bound up in the "ordered" scope, and therefore wouldn't be removed by the "Post.unscoped" part. In 4.0, we have deprecated all "eager" forms of scopes. So now you must write: class Post < ActiveRecord::Base default_scope { where(published: true) } scope :ordered, -> { order("created_at") } end This prevents the default scope getting bound up inside the "ordered" scope, which means we can now have a simpler/better/more natural implementation of default scoping. A knock on effect is that some things that didn't work properly now do. For example it was previously impossible to use #except to remove a part of the default scope, since the default scope was evaluated after the call to #except.
* Apply default scope when joining associations.Jon Leighton2013-06-281-0/+2
| | | | | | | | | | | | | | | | | | | For example: class Post < ActiveRecord::Base default_scope -> { where published: true } end class Comment belongs_to :post end When calling `Comment.join(:post)`, we expect to receive only comments on published posts, since that is the default scope for posts. Before this change, the default scope from `Post` was not applied, so we'd get comments on unpublished posts.
* do not load all child records for inverse caseNeeraj Singh2013-06-211-1/+1
| | | | | | | | | | | | | | currently `post.comments.find(Comment.first.id)` would load all comments for the given post to set the inverse association. This has a huge performance penalty. Because if post has 100k records and all these 100k records would be loaded in memory even though the comment id was supplied. Fix is to use in-memory records only if loaded? is true. Otherwise load the records using full sql. Fixes #10509
* Revert "Merge pull request #10566 from neerajdotname/10509d"Jon Leighton2013-06-191-1/+1
| | | | | | | | | | This reverts commit 2b817a5e89ac0e7aeb894a40ae7151a0cf3cef16, reversing changes made to 353a398bee68c5ea99d76ac7601de0a5fef6f4a5. Conflicts: activerecord/CHANGELOG.md Reason: the build broke
* do not load all child records for inverse caseNeeraj Singh2013-06-191-1/+1
| | | | | | | | | | | | | | currently `post.comments.find(Comment.first.id)` would load all comments for the given post to set the inverse association. This has a huge performance penalty. Because if post has 100k records and all these 100k records would be loaded in memory even though the comment id was supplied. Fix is to use in-memory records only if loaded? is true. Otherwise load the records using full sql. Fixes #10509
* `CollectionProxy#include?` returns `true` and `false` as documented.Yves Senn2013-06-181-1/+1
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-06-141-3/+4
|\ | | | | | | | | Conflicts: guides/source/upgrading_ruby_on_rails.md
| * enhanced comments for foreign_key_present? methodNeeraj Singh2013-05-231-3/+4
| |
* | bind values should not be merged between scopesAaron Patterson2013-06-111-1/+1
| |
* | stop adding a new method for touch callbacksAaron Patterson2013-06-111-29/+21
| |
* | push the touch method outside the evalAaron Patterson2013-06-111-13/+34
| |
* | remove unused variableAaron Patterson2013-06-111-1/+0
| |
* | check whether the association is constructible rather than checking constantsAaron Patterson2013-06-111-3/+3
| |
* | use attribute methods for finding key values rather than generating method namesAaron Patterson2013-06-111-3/+3
| |
* | push belongs_to counter cache method to a single methodAaron Patterson2013-06-111-17/+18
| |
* | push before_destroy counter cache method to a single methodAaron Patterson2013-06-111-12/+17
| |
* | remove evaled belongs_to counter cache methodAaron Patterson2013-06-111-8/+22
| |
* | adding callbacks should be privateAaron Patterson2013-06-111-4/+6
| |
* | remove evals from the associationAaron Patterson2013-06-111-8/+2
| |
* | reduce evals in depdendent associationsAaron Patterson2013-06-111-1/+2
| |
* | Getting rid of the +automatic_inverse_of: false+ option in associations in favorwangjohn2013-06-082-2/+2
| | | | | | | | | | of using +inverse_of: false+ option. Changing the documentation and adding a CHANGELOG entry for the automatic inverse detection feature.
* | Fix the `:primary_key` option for `has_many` associations.Yves Senn2013-05-231-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When removing records from a `has_many` association it used the `primary_key` defined on the association. Our test suite didn't fail because on all occurences of `:primary_key`, the specified column was available in both tables. This prevented the code from raising an exception but it still behaved badly. I added a test-case to prevent regressions that failed with: ``` 1) Error: HasManyAssociationsTest#test_has_many_assignment_with_custom_primary_key: ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: essays.first_name: UPDATE "essays" SET "writer_id" = NULL WHERE "essays"."writer_id" = ? AND "essays"."first_name" IS NULL ```
* | just set the default argument, a nil parent should be an errorAaron Patterson2013-05-211-2/+1
| |
* | fold the collection rather than multiple assigmentsAaron Patterson2013-05-211-3/+2
| |
* | use drop rather than calculate the array lengthAaron Patterson2013-05-211-1/+1
|/
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-05-195-7/+34
|\
| * copy edits[ci skip]Vijay Dev2013-05-191-11/+8
| |