aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
Commit message (Collapse)AuthorAgeFilesLines
* Revert "b9ea751d0e56bd00d341766977a607ed3f7ddd0f".José Valim2011-05-101-26/+27
| | | | | Wrapping each Record.associations.build in a transaction is going to make several unneeded queries. Reverting this commit also fixes #479.
* Merge pull request #399 from ernie/join_conditions_on_joinJon Leighton2011-05-051-3/+3
|\ | | | | Add association join conditions to JOIN clause, not WHERE
| * Add join conditions to JOIN clause, not WHEREErnie Miller2011-05-051-3/+3
| |
* | Merge pull request #358 from baroquebobcat/fix_find_or_create_masterAaron Patterson2011-05-051-3/+6
|\ \ | |/ |/| Fix for lighthouse #6741
| * Fix for lighthouse #6741Nick Howard2011-05-011-3/+6
| | | | | | | | | | | | | | - adds tests for find_or_create_by and find_or_initialize_by on has_many associations - changes the behavior of ActiveRecord::Associations::CollectionProxy#method_missing to differ to ActiveRecord::FinderMethods#find_or_instantiator_by_attributes for arg processing and saving so find_or_create_by's api on associations will be consistent w/ the api for model classes.
* | singular and collection relations in AR can now specify mass-assignment ↵Josh Kalderimis2011-05-013-20/+20
|/ | | | security options (:as and :without_protection) in build, create and create! methods.
* 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)
* Remove `#among?` from Active SupportPrem Sichanugrist2011-04-135-5/+5
| | | | | | After a long list of discussion about the performance problem from using varargs and the reason that we can't find a great pair for it, it would be best to remove support for it for now. It will come back if we can find a good pair for it. For now, Bon Voyage, `#among?`.
* Removing the scope-caching which happens on association proxies, because the ↵Jon Leighton2011-04-122-14/+0
| | | | query is already cached by the query cacher. For formalised proof see http://www.youtube.com/watch?v=wDefXLb-FDs
* Change Object#either? to Object#among? -- thanks to @jamesarosen for the ↵David Heinemeier Hansson2011-04-125-5/+5
| | | | suggestion!
* Using Object#in? and Object#either? in various placesPrem Sichanugrist2011-04-115-5/+14
| | | | There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
* TableAlias leg ordering has changed, so change accordinglyAaron Patterson2011-03-301-1/+1
|
* Make clearing of HABTM join table contents happen in an after_destory callback.Murray Steele2011-03-231-12/+12
| | | | The old method of redefining destroy meant that clearing the HABTM join table would happen as long as the call to destroy succeeded. Which meant if there was a before_destroy that stopped the instance being destroyed using normal means (returning false, raising ActiveRecord::Rollback) rather than exceptional means the join table would be cleared even though the instance wasn't destroyed. Doing it in an after_destroy hook avoids this and has the advantage of happening inside the DB transaction too.
* Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-161-1/+1
|\
| * Add additional text to NotImplementedErrors [#6328 state:resolved]Mike Gehard2011-03-121-1/+1
| | | | | | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* | Fix tests under postgres - we should always put conditions in the WHERE part ↵Jon Leighton2011-03-123-18/+22
| | | | | | | | not in ON constraints because postgres requires that the table has been joined before the condition references it.
* | Resolve some TODO comments which I decided did not need anything doneJon Leighton2011-03-122-8/+5
| |
* | Abstract some common code from AssociationScope and ↵Jon Leighton2011-03-113-97/+82
| | | | | | | | 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-103-18/+15
| | | | | | | | Reflection#chain and Reflection#options as they now no longer relate solely to through associations.
* | Move the code which builds a scope for through associations into a generic ↵Jon Leighton2011-03-107-209/+155
| | | | | | | | AssociationScope class which is capable of building a scope for any association.
* | Fix ↵Jon Leighton2011-03-071-1/+1
| | | | | | | | test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys
* | Refactor ThroughAssociation#join_to to be much smaller, and independent of ↵Jon Leighton2011-03-061-84/+28
| | | | | | | | construct_owner_conditions.
* | Refactor ThroughAssociation#tables to just be a flat array of tables in the ↵Jon Leighton2011-03-061-75/+70
| | | | | | | | order that they should be joined together.
* | Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-051-2/+2
|\| | | | | | | | | Conflicts: activerecord/CHANGELOG
| * Active Record typos.R.T. Lechow2011-03-051-2/+2
| |
| * When preloading has_and_belongs_to_many associations, we should only ↵Jon Leighton2011-03-041-2/+4
| | | | | | | | instantiate one AR object per actual record in the database. (Even when IM is off.)
| * Fix a couple of tests in join_model_test.rb which were failing when the ↵Jon Leighton2011-03-041-2/+2
| | | | | | | | identity map is turned off
* | Use Base#type_condition in JoinAssociationJon Leighton2011-03-051-15/+4
| |
* | Push source_type and polymorphic conditions out of ThroughAssociation and ↵Jon Leighton2011-03-052-35/+0
| | | | | | | | JoinDependency::JoinAssociation and into the reflection instead.
* | Add a test for STI on the through where the through is nested, and change ↵Jon Leighton2011-03-051-13/+22
| | | | | | | | the code which support this
* | Stop identity-mapping the through records in the preloader since I fixed the ↵Jon Leighton2011-03-041-5/+0
| | | | | | | | underlying problem in the habtm preloader.
* | Fix a couple of tests in join_model_test.rb which were failing when the ↵Jon Leighton2011-03-041-2/+2
| | | | | | | | identity map is turned off
* | When preloading has_and_belongs_to_many associations, we should only ↵Jon Leighton2011-03-041-2/+4
| | | | | | | | instantiate one AR object per actual record in the database. (Even when IM is off.)
* | Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-041-0/+5
|\|
* | Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-0442-2259/+3173
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-288-620/+612
| | | | | | | | ActiveRecord::Associations::ClassMethods to just ActiveRecord::Associations
| * Rewrote AssociationPreload.Jon Leighton2011-02-2811-0/+553
| |
| * Use proper objects to do the work to build the associations (adding methods, ↵Jon Leighton2011-02-2111-4/+501
| | | | | | | | callbacks etc) rather than calling a whole bunch of methods with rather long names.
| * Rename target_klass to klassJon Leighton2011-02-213-10/+10
| |
| * Delegate through_reflection and source_reflection to reflectionJon Leighton2011-02-213-34/+34
| |
| * Delegate Association#options to the reflection, and replace ↵Jon Leighton2011-02-217-47/+49
| | | | | | | | '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 Leighton2011-02-213-8/+2
| | | | | | | | proxy type on assignment.
| * Associations - where possible, call attributes methods rather than directly ↵Jon Leighton2011-02-2111-179/+179
| | | | | | | | accessing the instance variables
| * Initialize @target instead asking if it is defined.Emilio Tagua2011-02-181-1/+2
| |
| * Reindent and remove wrong line left in merge by mistake.Emilio Tagua2011-02-181-4/+3
| |
| * Merge remote branch 'rails/master' into identity_mapEmilio Tagua2011-02-1811-473/+527
| |\ | | | | | | | | | | | | | | | Conflicts: activerecord/lib/active_record/associations/association.rb activerecord/lib/active_record/fixtures.rb
| | * Split AssociationProxy into an Association class (and subclasses) which ↵Jon Leighton2011-02-189-276/+287
| | | | | | | | | | | | manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more.
| | * Add :nodoc: to ThroughAssociation and HasOneAssociationJon Leighton2011-02-182-2/+2
| | |
| | * Allow building and then later saving has_many :through records, such that ↵Jon Leighton2011-02-181-4/+46
| | | | | | | | | | | | the join record is automatically saved too. This requires the :inverse_of option to be set on the source association in the join model. See the CHANGELOG for details. [#4329 state:resolved]