aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
Commit message (Collapse)AuthorAgeFilesLines
* Removed support for deprecated `delete_sql` in associations.Neeraj Singh2013-07-031-15/+10
|
* Removed support for deprecated `insert_sql` in associations.Neeraj Singh2013-07-021-9/+5
|
* Deprecate #connection in favour of accessing it via the classBen Moss2013-03-091-3/+3
| | | | | This allows end-users to have a `connection` method on their models without clashing with ActiveRecord internals.
* Revert "Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql."Jon Leighton2012-08-011-15/+24
| | | | | | | | | This reverts commit 3803fcce26b837c0117f7d278b83c366dc4ed370. Conflicts: activerecord/CHANGELOG.md It will be deprecated only in 4.0, and removed properly in 4.1.
* Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql.Jon Leighton2012-07-201-24/+15
|
* Improve the derivation of HABTM assocation join table namesAndrew White2012-06-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve the derivation of HABTM join table name to take account of nesting. It now takes the table names of the two models, sorts them lexically and then joins them, stripping any common prefix from the second table name. Some examples: Top level models (Category <=> Product) Old: categories_products New: categories_products Top level models with a global table_name_prefix (Category <=> Product) Old: site_categories_products New: site_categories_products Nested models in a module without a table_name_prefix method (Admin::Category <=> Admin::Product) Old: categories_products New: categories_products Nested models in a module with a table_name_prefix method (Admin::Category <=> Admin::Product) Old: categories_products New: admin_categories_products Nested models in a parent model (Catalog::Category <=> Catalog::Product) Old: categories_products New: catalog_categories_products Nested models in different parent models (Catalog::Category <=> Content::Page) Old: categories_pages New: catalog_categories_content_pages Also as part of this commit the validity checks for HABTM assocations have been moved to ActiveRecord::Reflection One side effect of this is to move when the exceptions are raised from the point of declaration to when the association is built. This is consistant with other association validity checks.
* fix #delete_all with habtm with :delete_sqlJon Leighton2012-05-181-0/+1
|
* no longer need #delete_all_on_destroyJon Leighton2012-05-181-4/+0
|
* Perf: Don't load the association for #delete_all.Jon Leighton2012-05-181-5/+11
| | | | Bug #6289
* Fix #3672 again (dependent: delete_all perf)Jon Leighton2011-12-141-0/+4
|
* Make it the responsibility of the connection to hold onto an ARel visitor ↵Jon Leighton2011-08-081-2/+2
| | | | for generating SQL. This improves the code architecture generally, and solves some problems with marshalling. Adapter authors please take note: you now need to define an Adapter.visitor_for method, but it degrades gracefully with a deprecation warning for now.
* Only save the record once when calling create! on a collection association. ↵Jon Leighton2011-05-311-2/+8
| | | | Fixes #1360.
* Move the code which builds a scope for through associations into a generic ↵Jon Leighton2011-03-101-22/+0
| | | | AssociationScope class which is capable of building a scope for any association.
* Delegate Association#options to the reflection, and replace ↵Jon Leighton2011-02-211-3/+3
| | | | 'reflection.options' with 'options'. Also add through_options and source_options methods for through associations.
* Associations - where possible, call attributes methods rather than directly ↵Jon Leighton2011-02-211-14/+14
| | | | accessing the instance variables
* Split AssociationProxy into an Association class (and subclasses) which ↵Jon Leighton2011-02-181-19/+17
| | | | manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more.
* Get rid of AssociationCollection#save_recordJon Leighton2011-02-141-5/+3
|
* Add interpolation of association conditions back in, in the form of proc { ↵Jon Leighton2011-02-141-2/+2
| | | | ... } rather than instance_eval-ing strings
* Refactor the implementations of AssociatioCollection#delete and #destroy to ↵Jon Leighton2011-02-071-1/+1
| | | | be more consistent with each other, and to stop passing blocks around, thus making the execution easier to follow.
* Make record.association.destroy(*records) on habtm and hm:t only delete ↵Jon Leighton2011-02-071-1/+1
| | | | records in the join table. This is to make the destroy method more consistent across the different types of associations. For more details see the CHANGELOG entry.
* @join_table_name is no longer usedJon Leighton2011-01-301-2/+1
|
* Let's be less blasé about method visibility on association proxiesJon Leighton2011-01-301-9/+10
|
* Removed support for accessing attributes on a has_and_belongs_to_many join ↵Jon Leighton2011-01-161-62/+6
| | | | table. This has been documented as deprecated behaviour since April 2006. Please use has_many :through instead. A deprecation warning will be added to the 3-0-stable branch for the 3.0.4 release.
* Construct an actual ActiveRecord::Relation object for the association scope, ↵Jon Leighton2011-01-071-8/+8
| | | | 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.
* avoid creating so many Arel::Table objectsAaron Patterson2011-01-051-6/+9
|
* we have a method for this, so let's use itAaron Patterson2011-01-051-2/+2
|
* use arel ast construction rather than generating stringsAaron Patterson2011-01-051-1/+7
|
* use arel to construct AST rather than generate stringsAaron Patterson2011-01-051-2/+3
|
* Explicitly select * from has_and_belongs_to_many association tables, ↵Raimonds Simanovskis2011-01-041-1/+2
| | | | | simplify exists? query Previous version (after commit 3103296a61709e808aa89c3d37cf22bcdbc5a675) was generating wrong SQL for Oracle when calling exists? method on HABTM association.
* Create the association scope directly rather than going through with_scopeJon Leighton2011-01-031-1/+1
|
* Let AssociationCollection#find use #scoped to do its finding. Note that I am ↵Jon Leighton2011-01-031-15/+19
| | | | removing test_polymorphic_has_many_going_through_join_model_with_disabled_include, since this specifies different behaviour for an association than for a regular scope. It seems reasonable to expect scopes and association proxies to behave in roughly the same way rather than having subtle differences.
* Rename AssociationReflection#primary_key_name to foreign_key, since the ↵Jon Leighton2010-12-311-2/+2
| | | | options key which it relates to is :foreign_key
* Refactor we_can_set_the_inverse_on_this? to use a less bizarre name amongst ↵Jon Leighton2010-12-261-0/+4
| | | | other things
* Associations: DRY up the code which is generating conditions, and make it ↵Jon Leighton2010-12-261-4/+6
| | | | all use arel rather than SQL strings
* Remove unnecessary overloaded methods create, create! and create_record from ↵Jon Leighton2010-12-201-18/+0
| | | | HasAndBelongsToManyAssociation
* Specify insert_record with NotImplementedError in AssociationCollection, to ↵Jon Leighton2010-12-201-5/+1
| | | | indicate that subclasses should implement it. Also add save_record to reduce duplication.
* remove calls to deprecated methodsAaron Patterson2010-12-021-2/+3
|
* removing some calls to insert on arelAaron Patterson2010-12-021-3/+4
|
* Partialy revert f1c13b0dd7b22b5f6289ca1a09f1d7a8c7c8584bJosé Valim2010-11-281-2/+2
|
* Remove explicit return.Emilio Tagua2010-11-251-2/+2
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* use persisted? instead of new_record? wherever possibleDavid Chelimsky2010-11-091-1/+1
| | | | | | | | | | | - 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>
* Refactoring: replace the mix of variables like @finder_sql, @counter_sql, ↵Jon Leighton2010-10-301-19/+18
| | | | etc with just a single scope hash (created on initialization of the proxy). This is now used consistently across all associations. Therefore, all you have to do to ensure finding/counting etc is done correctly is implement the scope correctly.
* Perf: refactor method.Emilio Tagua2010-09-221-11/+8
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* do not pass nil values to arelAaron Patterson2010-09-211-1/+1
|
* mark SQL literals as SQL literalsAaron Patterson2010-08-251-1/+1
|
* marking sql literals as sql literalsAaron Patterson2010-08-231-1/+1
|
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-3/+3
| | | | 's/[ \t]*$//' -i {} \;)
* Removing most of the symbol to proc usage in Active RecordPrem Sichanugrist2010-08-131-1/+1
| | | | This will hopefully make Active Record run a bit more faster.
* do not use arel constants directlyAaron Patterson2010-08-131-1/+1
|
* symbol to proc is slow, we should avoid itAaron Patterson2010-08-131-1/+1
|