aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* rename `Relation#uniq` to `Relation#distinct`. `#uniq` still works.Yves Senn2013-03-151-1/+1
| | | | | | | | The similarity of `Relation#uniq` to `Array#uniq` is confusing. Since our Relation API is close to SQL terms I renamed `#uniq` to `#distinct`. There is no deprecation. `#uniq` and `#uniq!` are aliases and will continue to work. I also updated the documentation to promote the use of `#distinct`.
* Revert "Merge pull request #8989 from robertomiranda/use-rails-4-find-by"Guillermo Iguaran2013-01-181-8/+8
| | | | | This reverts commit 637a7d9d357a0f3f725b0548282ca8c5e7d4af4a, reversing changes made to 5937bd02dee112646469848d7fe8a8bfcef5b4c1.
* User Rails 4 find_byrobertomiranda2013-01-181-8/+8
|
* Merge and add tests related to 5215Vipul A M2012-11-121-6/+11
|
* Count returns 0 without querying if parent is not savedFrancesco Rodriguez2012-10-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Patches `CollectionAssociation#count` to return 0 without querying if the parent record is new. Consider the following code: class Account has_many :dossiers end class Dossier belongs_to :account end a = Account.new a.dossiers.build # before patch a.dossiers.count # SELECT COUNT(*) FROM "dossiers" WHERE "dossiers"."account_id" IS NULL # => 0 # after a.dosiers.count # fires without sql query # => 0 Fixes #1856.
* Remove ActiveRecord::Base.to_aJon Leighton2012-08-031-2/+2
| | | | | On reflection, it seems like a bit of a weird method to have on ActiveRecord::Base, and it shouldn't be needed most of the time anyway.
* Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql.Jon Leighton2012-08-011-6/+21
|
* Revert "Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql."Jon Leighton2012-08-011-0/+69
| | | | | | | | | This reverts commit 3803fcce26b837c0117f7d278b83c366dc4ed370. Conflicts: activerecord/CHANGELOG.md It will be deprecated only in 4.0, and removed properly in 4.1.
* AR::Relation#order: make new order prepend old oneBogdan Gusiev2012-07-311-2/+2
| | | | | | | User.order("name asc").order("created_at desc") # SELECT * FROM users ORDER BY created_at desc, name asc This also affects order defined in `default_scope` or any kind of associations.
* Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-271-5/+5
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* ActiveRecord::Base.all returns a Relation.Jon Leighton2012-07-271-7/+7
| | | | | | | | | | | Previously it returned an Array. If you want an array, call e.g. `Post.to_a` rather than `Post.all`. This is more explicit. In most cases this should not break existing code, since Relations use method_missing to delegate unknown methods to #to_a anyway.
* Deprecate update_column in favor of update_columns.Rafael Mendonça França2012-07-241-1/+1
| | | | Closes #1190
* Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql.Jon Leighton2012-07-201-69/+0
|
* Improve the derivation of HABTM assocation join table namesAndrew White2012-06-221-3/+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 fragile #assert_queries implementation and usages.Steve Jorgensen2012-06-091-2/+5
| | | | | | | | | Several tests that passed when run in the order they are loaded by rake test were failing when run in different sequences due to problems with the implementation of assert_queries and assert_no_queries as well as incorrect assumptions made about how many queries might be executed by a database adapter in various cases.
* fix #delete_all with habtm with :delete_sqlJon Leighton2012-05-181-0/+6
|
* quarantine deprecated testsJon Leighton2012-05-181-20/+0
|
* Merge pull request #5453 from ↵Aaron Patterson2012-05-161-0/+6
|\ | | | | | | | | JonRowe/patch_uniq_has_and_belongs_to_many_when_already_loaded When Active Record has already loaded a unique association `.size` returns the wrong number.
| * when using a preloaded array and the uniq flag is set then return the size ↵Jon Rowe2012-03-151-0/+6
| | | | | | | | of the uniq array
* | Remove #=== quirkJon Leighton2012-05-111-5/+0
| | | | | | | | Makes it consistent with Relation. Can't see a use for this.
* | CollectionProxy < RelationJon Leighton2012-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This helps bring the interfaces of CollectionProxy and Relation closer together, and reduces the delegation backflips we need to perform. For example, first_or_create is defined thus: class ActiveRecord::Relation def first_or_create(...) first || create(...) end end If CollectionProxy < Relation, then post.comments.first_or_create will hit the association's #create method which will actually add the new record to the association, just as post.comments.create would. With the previous delegation, post.comments.first_or_create expands to post.comments.scoped.first_or_create, where post.comments.scoped has no knowledge of the association.
* | more deprecations manually fixedJon Leighton2012-04-271-7/+7
| |
* | find and replace deprecated keysJon Leighton2012-04-271-7/+7
| |
* | %s/find(:\(first\|last\|all\), \([^()]*\))/scoped(\2).\1/gcI amongst other ↵Jon Leighton2012-04-271-7/+7
| | | | | | | | things
* | remove calls to find(:first), find(:last) and find(:all)Jon Leighton2012-04-261-8/+8
| |
* | remove deprecate #calculate callsJon Leighton2012-04-261-7/+0
| |
* | fix testsJon Leighton2012-04-131-4/+4
|/
* Deprecate inferred JOINs with includes + SQL snippets.Jon Leighton2012-01-161-2/+14
| | | | | | See the CHANGELOG for details. Fixes #950.
* Revert "Deprecate implicit eager loading. Closes #950."Jon Leighton2012-01-161-2/+2
| | | | This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
* Deprecate implicit eager loading. Closes #950.Jon Leighton2011-12-291-2/+2
|
* Delete obsolete commentJon Leighton2011-12-161-1/+0
|
* Cache columns at the model level.Jon Leighton2011-12-161-2/+2
| | | | Allows two models to use the same table but have different primary keys.
* Use `table_exists?` from the schema cache.Aaron Patterson2011-12-091-3/+3
|
* Deprecate set_table_name in favour of self.table_name= or defining your own ↵Jon Leighton2011-11-291-5/+5
| | | | method.
* use GeneratedFeatureMethods module for associationsJosh Susser2011-11-271-1/+21
|
* Fixed failed test under 1.8.7 as map.keys order in indeterminableRocky Jaiswal2011-09-281-1/+1
|
* Merge pull request #3030 from htanata/fix_habtm_select_query_methodJon Leighton2011-09-261-0/+8
| | | | Fix: habtm doesn't respect select query method
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-2/+2
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* added an alias for new to build to the AR collection proxy, this corrects an ↵Josh Kalderimis2011-06-011-0/+15
| | | | issue where the collection proxies were not consistent
* added assertion for non-standard primary_key on models used in the ↵Marian Rudzynski2011-05-261-0/+3
| | | | primary_key test
* use association_primary_key in AssociationScope#add_constraintsMarian Rudzynski2011-05-261-0/+7
|
* Added new #update_column method.Sebastian Martinez2011-03-271-1/+1
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Revert "Removed #update_attribute method. New #update_column method."Sebastian Martinez2011-03-271-1/+1
| | | | | | This reverts commit 45c233ef819dc7b67e259dd73f24721fec28b8c8. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Removed #update_attribute method. New #update_column method.Sebastian Martinez2011-03-261-1/+1
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-041-96/+30
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Add interpolation of association conditions back in, in the form of proc { ↵Jon Leighton2011-02-141-1/+1
| | | | | | | | ... } rather than instance_eval-ing strings
| * Make record.association.destroy(*records) on habtm and hm:t only delete ↵Jon Leighton2011-02-071-8/+22
| | | | | | | | 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.
| * adjust query counts to be consistent across databases, make sure database ↵Aaron Patterson2011-02-041-3/+6
| | | | | | | | log the same things
| * column cache now lives on the connection poolAaron Patterson2011-02-041-2/+2
| |