aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader/association.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge pull request #21033 from dgynn/preloader_build_scope_tuningArthur Nogueira Neves2015-10-041-1/+3
|\ \ | |/ |/| Skip _select! call unless needed for preloader
| * skip _select! call unless :select values are specifiedDave Gynn2015-07-261-1/+3
| | | | | | | | | | the default scope will select all fields. removing this improves performance and reduces String creation.
* | Include association's `unscope` when preloadingJimmy Bourassa2015-09-091-1/+1
|/
* Remove most type related predicates from `Column`Sean Griffin2015-01-301-2/+2
| | | | | | Remaining are `limit`, `precision`, `scale`, and `type` (the symbol version). These will remain on the column, since they mirror the options to the `column` method in the schema definition DSL
* Don't rely on the internal representation of join valuesSean Griffin2015-01-271-1/+5
| | | | | I'm going to be extracting this logic into a clause class, things need to go through a method and not access the values hash directly.
* Remove all references to `where_values` in association codeSean Griffin2015-01-251-6/+3
|
* Don't rely as much on the structure of the values hash in associationsSean Griffin2015-01-251-1/+1
| | | | | | | | | The structure of `values[:where]` is going to change, with an intermediate definition of `where_values` to aid the refactoring. Accessing `values[:where]` directly messes with that, signficantly. The array wrapping is no longer necessary, since `where_values` will always return an array.
* Return a null column from `column_for_attribute` when no column exists.Rafael Mendonça França2015-01-041-2/+2
| | | | | | | | This reverts commit ae96f229f6501d8635811d6b22d75d43cdb880a4. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/attribute_methods.rb
* Go through normal `where` logic when preloading associationsSean Griffin2014-12-261-1/+1
| | | | | | | | | | This will allow eager type casting to take place as needed. There doesn't seem to be any particular reason that the `in` statement was forced for single values, and the commit message where it was introduced gives no context. See https://github.com/rails/rails/commit/d90b4e2615e8048fdeffc6dffe3246704adee01f
* Fix includes on association with a scope containing joins along with conditionssiddharth@vinsol.com2014-11-211-8/+2
| | | | on the joined assoiciation
* Merge pull request #17360 from bronzle/includes_and_unscopedYves Senn2014-11-051-0/+1
|\ | | | | | | copy reflection_scopes’s unscoped value when building scope for preloading
| * copy reflection_scopes’s unscoped value when building scope for ↵Byron Bischoff2014-10-221-0/+4
|/ | | | preloading, fixes #11036
* `preload` preserves readonly flag on associations. #15853Yves Senn2014-06-251-0/+4
| | | | | | This is a partial fix for #15853. It only works when a `preload` is issued and not an `eager_load`. I've added a skipped failing test-case to keep in mind that we need to deal with `eager_load`.
* Add a deprecation cycle for `NullColumn` from `column_for_attribute`Sean Griffin2014-06-231-2/+2
| | | | | | This is public API, and `simple_form` depends on the `nil` return value. We need to go through a deprecation cycle to return a null object. If people want hash access, they can access the hash.
* Use null column for association key typesSean Griffin2014-06-041-4/+2
|
* Fix regression on eager loading association based on SQL query ratherLauro Caetano2014-06-031-2/+4
| | | | | | than existing column. Fixes #15480.
* Merge pull request #14855 from laurocaetano/fix_polymorphic_with_string_keyYves Senn2014-05-211-4/+25
|\ | | | | | | Fix polymorphic eager load with foreign_key as String.
| * Fix polymorphic eager load with foreign_key as String.Lauro Caetano2014-05-201-2/+17
|/ | | | | | | | | The foreign_key could be `String` and just doing `owners_map[owner_key]` could return `nil`. To prevent this bug, we should `to_s` both keys if their types are different. Fixes #14734.
* Merge branch 'master' into adequaterecordAaron Patterson2014-04-251-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (28 commits) move AR length validation tests into separate test-case. No need for trailing slash on migration path. reset `@arel` when modifying a Relation in place. PostgreSQL Timestamps always map to `:datetime`. [ci skip] Improve formatting and yml Fix a typo in the doc of forty_two AR FinderMethod Improve readability of contributing to rails guide. [ci skip] Precompile the image we're referencing, too. `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions. Fixed an issue with migrating legacy json cookies. Correct comment [ci skip] Perfer to define methods instead of calling test Fix syntax error Add CHANGELOG entry for #14757 [ci skip] Fix run-on sentences and improve grammar [skip ci] Add test for using ActionView::Helpers::FormHelper.label with block and html select! renamed to avoid name collision Array#select! Rearrange deck chairs on the titanic. Organize connection handling test cases. Change favicon_link_tag helper mimetype from image/vnd.microsoft.icon to image/x-icon. ActionController::Renderers documentation fix ...
| * select! renamed to avoid name collision Array#select!Earl J St Sauver2014-04-211-1/+1
| | | | | | | | | | | | | | | | Fixes #14752 Select mimics the block interface of arrays, but does not mock the block interface for select!. This change moves the api to be a private method, _select!.
* | Merge branch 'master' into set_bindsAaron Patterson2014-01-111-24/+42
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
| * hash insertion order doesn't matter anymore, so only loop over theAaron Patterson2013-09-251-4/+2
| | | | | | | | owners once
| * keep preloaded records in a list rather than extract from a hashAaron Patterson2013-09-251-13/+9
| |
| * push slice loading to it's own method so we can remove the type castingAaron Patterson2013-09-241-13/+8
| | | | | | | | code
| * guarantee that `klass` is not nil inside the preloader objectsAaron Patterson2013-09-241-1/+1
| |
| * eliminate the `loaded?` conditionalAaron Patterson2013-09-241-7/+0
| |
| * push preloaded test up to the factory method so we can eliminateAaron Patterson2013-09-241-3/+1
| | | | | | | | conditionals from the individual preloaded classes
| * pass the preloader down so we only have to construct oneAaron Patterson2013-09-231-5/+5
| |
| * fix variable names and speed up relation orderingAaron Patterson2013-09-231-9/+1
| |
| * hm:t preloading will respect order set on the RHS associationAaron Patterson2013-09-231-2/+22
| |
| * cache associated target records hashAaron Patterson2013-09-201-17/+11
| |
| * preserve order on the RHS queryAaron Patterson2013-09-201-0/+8
| |
| * push `run` up to preloadAaron Patterson2013-09-201-3/+7
| |
| * exposing target records on the preloaderAaron Patterson2013-09-201-14/+27
| |
| * correctly typecast keys, remove conditionals, reduce object allocationsAaron Patterson2013-08-281-7/+6
| |
| * 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-281-1/+5
| |
| * use flat_mapNeeraj Singh2013-08-031-1/+1
| |
| * 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
|/
* 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-131-27/+22
|
* Fix #5667. Preloading should ignore scoping.Jon Leighton2012-03-301-2/+3
|