aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge branch 'master' into set_bindsAaron Patterson2014-01-116-116/+106
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (2794 commits) doc, API example on how to use `Model#exists?` with multiple IDs. [ci skip] Restore DATABASE_URL even if it's nil in connection_handler test [ci skip] - error_messages_for has been deprecated since 2.3.8 - lets reduce any confusion for users Ensure Active Record connection consistency Revert "ask the fixture set for the sql statements" Check `respond_to` before delegation due to: https://github.com/ruby/ruby/commit/d781caaf313b8649948c107bba277e5ad7307314 Adding Hash#compact and Hash#compact! methods MySQL version 4.1 was EOL on December 31, 2009 We should at least recommend modern versions of MySQL to users. clear cache on body close so that cache remains during rendering add a more restricted codepath for templates fixes #13390 refactor generator tests to use block form of Tempfile Fix typo [ci skip] Move finish_template as the last public method in the generator Minor typos fix [ci skip] make `change_column_null` reversible. Closes #13576. create/drop test and development databases only if RAILS_ENV is nil Revert "Speedup String#to" typo fix in test name. [ci skip]. `core_ext/string/access.rb` test what we are documenting. Fix typo in image_tag documentation ... Conflicts: activerecord/lib/active_record/associations/join_dependency/join_association.rb activerecord/lib/active_record/relation/query_methods.rb
| * remove the nil check from set_inverse_instanceAaron Patterson2013-12-121-1/+1
| | | | | | | | | | methods that call set_inverse_instance with a record will not have to pay the cost of a nil check on every call
| * read the association instead of sendingAaron Patterson2013-10-141-1/+3
| |
| * simplify populating the ordering hashAaron Patterson2013-10-141-10/+5
| |
| * the preloader for the RHS has all the preloaded records, so ask itAaron Patterson2013-10-141-3/+3
| |
| * only calculate offset index once. #12537Aaron Patterson2013-10-141-6/+10
| |
| * Drop unused iterator varVipul A M2013-10-131-1/+1
| |
| * 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.
* | push binds through relation objectsAaron Patterson2013-05-201-0/+3
|/
* 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).