aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader
Commit message (Collapse)AuthorAgeFilesLines
* remove the HABTM preloaderAaron Patterson2013-10-021-71/+0
|
* remove initialize methodAaron Patterson2013-09-251-4/+0
|
* extract association resetting to a methodAaron Patterson2013-09-251-9/+16
|
* hash insertion order doesn't matter anymore, so only loop over theAaron Patterson2013-09-251-4/+2
| | | | owners once
* always populate the preloaded records instance variable so we can removeAaron Patterson2013-09-252-10/+5
| | | | the @associated_records_by_owner ivar
* keep preloaded records in a list rather than extract from a hashAaron Patterson2013-09-253-16/+21
|
* push slice loading to it's own method so we can remove the type castingAaron Patterson2013-09-242-24/+20
| | | | code
* guarantee that `klass` is not nil inside the preloader objectsAaron Patterson2013-09-241-1/+1
|
* eliminate unused ivarAaron Patterson2013-09-241-1/+0
|
* all records have a preloaded, so eliminate that conditionalAaron Patterson2013-09-241-11/+7
|
* eliminate the `loaded?` conditionalAaron Patterson2013-09-242-10/+1
|
* push preloaded test up to the factory method so we can eliminateAaron Patterson2013-09-242-6/+4
| | | | conditionals from the individual preloaded classes
* we can't sort by lhs since the middle records have difference classesAaron Patterson2013-09-231-19/+19
| | | | and possibly different rules for finding those objects
* pass the preloader down so we only have to construct oneAaron Patterson2013-09-236-19/+17
|
* remove state from the preloaderAaron Patterson2013-09-231-10/+9
|
* only do the should_reset test onceAaron Patterson2013-09-231-6/+6
|
* fix variable names and speed up relation orderingAaron Patterson2013-09-232-16/+12
|
* hm:t preloading will respect order set on the RHS associationAaron Patterson2013-09-234-7/+52
|
* cache associated target records hashAaron Patterson2013-09-201-17/+11
|
* combine methods so we can reuse preloadersAaron Patterson2013-09-201-19/+18
|
* return a list rather than hashAaron Patterson2013-09-201-7/+13
|
* preserve order on the RHS queryAaron Patterson2013-09-201-0/+8
|
* split up construction and mutationAaron Patterson2013-09-201-1/+4
|
* push `run` up to preloadAaron Patterson2013-09-202-4/+11
|
* exposing target records on the preloaderAaron Patterson2013-09-202-16/+29
|
* correctly typecast keys, remove conditionals, reduce object allocationsAaron Patterson2013-08-282-7/+11
|
* no need to to_a the scopeAaron Patterson2013-08-281-1/+1
|
* remove extra flat_map arrayAaron Patterson2013-08-281-8/+9
|
* avoid extra empty array allocationAaron Patterson2013-08-281-10/+10
|
* extract owner id calculation to a methodAaron Patterson2013-08-281-1/+5
|
* only call to_a when we have toAaron Patterson2013-08-282-2/+6
|
* remove intermediate variableAaron Patterson2013-08-271-3/+1
|
* cache association reset calculationAaron Patterson2013-08-271-4/+4
|
* query the association rather than send the method for the association nameAaron Patterson2013-08-271-5/+6
|
* use flat_mapNeeraj Singh2013-08-031-1/+1
|
* don't shadow `through_scope` method name with local var.Yves Senn2013-06-301-7/+7
|
* Simplify/fix implementation of default scopesJon Leighton2013-06-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation was necessary in order to support stuff like: class Post < ActiveRecord::Base default_scope where(published: true) scope :ordered, order("created_at") end If we didn't evaluate the default scope at the last possible moment before sending the SQL to the database, it would become impossible to do: Post.unscoped.ordered This is because the default scope would already be bound up in the "ordered" scope, and therefore wouldn't be removed by the "Post.unscoped" part. In 4.0, we have deprecated all "eager" forms of scopes. So now you must write: class Post < ActiveRecord::Base default_scope { where(published: true) } scope :ordered, -> { order("created_at") } end This prevents the default scope getting bound up inside the "ordered" scope, which means we can now have a simpler/better/more natural implementation of default scoping. A knock on effect is that some things that didn't work properly now do. For example it was previously impossible to use #except to remove a part of the default scope, since the default scope was evaluated after the call to #except.
* 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.