aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/join_dependency
Commit message (Collapse)AuthorAgeFilesLines
...
* make sure scope_chain_items has consistent typesAaron Patterson2013-07-161-7/+9
|
* 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.
* stop doing assingments in an iteratorAaron Patterson2013-05-171-2/+6
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-04-111-1/+1
|\ | | | | | | | | Conflicts: guides/source/action_mailer_basics.md
| * JoinPart is no longer an abstract classNeeraj Singh2013-04-081-1/+1
| |
* | rdoc for some of the methods in JoinDependencyNeeraj Singh2013-04-101-0/+15
| |
* | While merging relations preserve context for joinsJared Armstrong and Neeraj Singh2013-04-101-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #3002. Also see #5494. ``` class Comment < ActiveRecord::Base belongs_to :post end class Author < ActiveRecord::Base has_many :posts end class Post < ActiveRecord::Base belongs_to :author has_many :comments end ``` `Comment.joins(:post).merge(Post.joins(:author).merge(Author.where(:name => "Joe Blogs"))).all` would fail with `ActiveRecord::ConfigurationError: Association named 'author' was not found on Comment`. It is failing because `all` is being called on relation which looks like this after all the merging: `{:joins=>[:post, :author], :where=>[#<Arel::Nodes::Equality: ....}`. In this relation all the context that `Post` was joined with `Author` is lost and hence the error that `author` was not found on `Comment`. Ths solution is to build JoinAssociation when two relations with join information are being merged. And later while building the arel use the previously built `JoinAssociation` record in `JoinDependency#graft` to build the right from clause. Thanks to Jared Armstrong (https://github.com/armstrjare) for most of the work. I ported it to make it compatible with new code base.
* | changed variable name active_record => base_klassNeeraj Singh2013-04-093-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current code stores the klass name in active_record and this is used throughout. While reviewing the code time and again I had the mental picture of active_record being an instance of a klass. However here the actual klass is being stored in @active_record. Secondly at two different places while referring to @active_record the comment refers to it as base klass. All this points to active_record being not the best variable name. So I thought it is better to replace active_record with base_klass. This change is confined to JoinDependency, JoinBase, JoinPart and JoinAssociation - all joining related work.
* | not a relation. it's an arel select managerNeeraj Singh2013-04-021-4/+4
|/
* No need to send public methodsAkira Matsuda2013-02-261-1/+1
|
* Merge pull request #4976 from kreynolds/fix_eager_without_pkeyJon Leighton2012-09-071-1/+1
|\ | | | | Fix eagerly loading associations without primary keys
| * Fix eagerly loading associations without primary keysKelley Reynolds2012-02-091-1/+1
| |
* | Represent association scope options as AR::Relations insternally.Jon Leighton2012-07-131-18/+15
| |
* | Revert "Merge pull request #5494 from ↵Jon Leighton2012-05-051-6/+1
| | | | | | | | | | | | | | armstrjare/active_record_relation_keep_association_join_context_on_merge" This reverts commit dcd04e76179611a9db28c9e391aa7d6c2a5b046a, reversing changes made to 58a49875df63729f07a9a81d1ee349087d258df5.
* | Allow ActiveRecord::Relation merges to maintain context of joined associationsJared Armstrong2012-05-041-1/+6
|/
* Avoid sanitize_sql when we can use Relation#where insteadJon Leighton2012-01-161-2/+5
|
* Fix problem with loading polymorphic associations which have been defined in ↵Jon Leighton2011-05-221-3/+7
| | | | an abstract superclass. Fixes #552.
* Add join conditions to JOIN clause, not WHEREErnie Miller2011-05-051-3/+3
|
* Extract the constraint-building for joins in JoinAssociation into a separate ↵Jon Leighton2011-04-141-8/+14
| | | | method to make it easy to change/override (requested by Ernie Miller so that MetaWhere can add to it easily)
* TableAlias leg ordering has changed, so change accordinglyAaron Patterson2011-03-301-1/+1
|
* Fix tests under postgres - we should always put conditions in the WHERE part ↵Jon Leighton2011-03-121-8/+11
| | | | not in ON constraints because postgres requires that the table has been joined before the condition references it.
* Abstract some common code from AssociationScope and ↵Jon Leighton2011-03-111-53/+12
| | | | JoinDependency::JoinAssociation into a JoinHelper module
* Refactor JoinAssociationJon Leighton2011-03-101-100/+54
|
* Rename Reflection#through_reflection_chain and #through_options to ↵Jon Leighton2011-03-101-9/+7
| | | | Reflection#chain and Reflection#options as they now no longer relate solely to through associations.
* Use Base#type_condition in JoinAssociationJon Leighton2011-03-051-15/+4
|
* Push source_type and polymorphic conditions out of ThroughAssociation and ↵Jon Leighton2011-03-051-18/+0
| | | | JoinDependency::JoinAssociation and into the reflection instead.
* Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-041-177/+157
| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG activerecord/lib/active_record/association_preload.rb activerecord/lib/active_record/associations.rb activerecord/lib/active_record/associations/class_methods/join_dependency.rb activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb activerecord/lib/active_record/associations/has_many_association.rb activerecord/lib/active_record/associations/has_many_through_association.rb activerecord/lib/active_record/associations/has_one_association.rb activerecord/lib/active_record/associations/has_one_through_association.rb activerecord/lib/active_record/associations/through_association_scope.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/associations/has_many_through_associations_test.rb activerecord/test/cases/associations/has_one_through_associations_test.rb activerecord/test/cases/reflection_test.rb activerecord/test/cases/relations_test.rb activerecord/test/fixtures/memberships.yml activerecord/test/models/categorization.rb activerecord/test/models/category.rb activerecord/test/models/member.rb activerecord/test/models/reference.rb activerecord/test/models/tagging.rb
* Move JoinDependency and friends from ↵Jon Leighton2011-02-283-0/+381
ActiveRecord::Associations::ClassMethods to just ActiveRecord::Associations