aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader
Commit message (Collapse)AuthorAgeFilesLines
* Avoid iterating over records hash when not necessaryCarlos Antonio da Silva2013-04-071-2/+6
| | | | | | If the reflection scope is not flagged with distinct value, there is no need to iterate over the records, so we avoid that by doing the check before iterating rather than inside the iteration block.
* each to each_value; remove unused varsVipul A M2013-04-071-1/+1
|
* 1. Change from each to each_value since we did not use keyVipul A M2013-03-191-1/+1
| | | | 2. drop assignment of value to sum in test
* 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`.
* don't apply invalid ordering when preloading hmt associations.Yves Senn2013-02-241-2/+2
| | | | | | | | | | | | | | | closes #8663. When preloading a hmt association there two possible scenarios: 1.) preload with 2 queries: first hm association, then hmt with id IN () 2.) preload with join: hmt association is loaded with a join on the hm association The bug was happening in scenario 1.) with a normal order clause on the hmt association. The ordering was also applied when loading the hm association, which resulted in the error. This patch only applies the ordering the the hm-relation if we are performing a join (2). Otherwise the order will only appear in the second query (1).
* don't cache invalid subsets when preloading hmt associations.Yves Senn2013-02-141-1/+2
| | | | closes #8423.
* Eager loading made to use relation's in_clause_length instead of host's one ↵Boris Staal2012-12-201-1/+1
| | | | (fixes #8474)
* Revert "Use flat_map { } instead of map {}.flatten"Santiago Pastorino2012-10-051-1/+1
| | | | | | | | | | | This reverts commit abf8de85519141496a6773310964ec03f6106f3f. We should take a deeper look to those cases flat_map doesn't do deep flattening. irb(main):002:0> [[[1,3], [1,2]]].map{|i| i}.flatten => [1, 3, 1, 2] irb(main):003:0> [[[1,3], [1,2]]].flat_map{|i| i} => [[1, 3], [1, 2]]
* Use flat_map { } instead of map {}.flattenSantiago Pastorino2012-10-051-1/+1
|
* s/scoped/scope/Jon Leighton2012-08-011-4/+4
|
* Convert association macros to the new syntaxJon Leighton2012-07-201-1/+1
|
* Represent association scope options as AR::Relations insternally.Jon Leighton2012-07-135-46/+36
|
* 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 #5667. Preloading should ignore scoping.Jon Leighton2012-03-301-2/+3
|
* Avoid sanitize_sql when we can use Relation#where insteadJon Leighton2012-01-161-8/+6
|
* Revert "Deprecate implicit eager loading. Closes #950."Jon Leighton2012-01-162-2/+0
| | | | This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
* Deprecate implicit eager loading. Closes #950.Jon Leighton2011-12-292-0/+2
|
* Make it the responsibility of the connection to hold onto an ARel visitor ↵Jon Leighton2011-08-081-1/+1
| | | | 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.
* reduce calls to owners_by_key and to read_attribute, respond_to? etcAaron Patterson2011-07-011-2/+3
|
* 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.
* 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-041-2/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | 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
* Rewrote AssociationPreload.Jon Leighton2011-02-2810-0/+376