aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader
Commit message (Collapse)AuthorAgeFilesLines
* Remove single element array preprocessRyuta Kamizono2017-07-261-1/+1
| | | | | Since 213796f, array predicate handler supports making binds, so the preprocess is no longer needed.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-199-0/+18
|
* Merge pull request #29033 from kamipo/make_preload_query_to_prepared_statementsSean Griffin2017-07-181-1/+1
|\ | | | | Make preload query to preparable
| * Make preload query to preparableRyuta Kamizono2017-07-071-1/+1
| | | | | | | | | | | | | | Currently preload query cannot be prepared statements even if `prepared_statements: true` due to array handler in predicate builder doesn't support making bind params. This makes preload query to preparable by don't passing array value if possible.
* | Fix unscoping `default_scope` for `Preloader`Ryuta Kamizono2017-07-191-1/+11
|/
* Fix preloading association with scope including joinsRyuta Kamizono2017-07-042-46/+25
|
* Remove unused `association_key` and `table` methods in `Preloader::Association`Ryuta Kamizono2017-07-041-10/+0
| | | | These are no longer used since b98668decb9712f26118de57623fd15d7d28646d.
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-029-9/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-019-0/+9
|
* Merge pull request #29129 from kamipo/prevent_extra_through_scopeRafael França2017-06-281-2/+4
|\ | | | | Prevent extra `through_scope`
| * Prevent extra `through_scope`Ryuta Kamizono2017-05-181-2/+4
| | | | | | | | We can reuse `through_scope` for `reset_association`.
* | Don't expose methods and attrs for internal usageRyuta Kamizono2017-05-303-6/+5
|/
* Remove useless `target_records_from_association`Ryuta Kamizono2017-05-041-11/+3
| | | | Since through association is always loaded by `preloader.preload`.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-292-4/+4
|
* Merge pull request #26379 from kamipo/remove_unnecessary_query_scopeAndrew White2016-09-051-4/+0
|\ | | | | Remove unnecessary `query_scope`
| * Remove unnecessary `query_scope`Ryuta Kamizono2016-08-161-4/+0
| |
* | Ensure that inverse associations are set before running callbacksSean Griffin2016-08-313-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a parent association was accessed in an `after_find` or `after_initialize` callback, it would always end up loading the association, and then immediately overwriting the association we just loaded. If this occurred in a way that the parent's `current_scope` was set to eager load the child, this would result in an infinite loop and eventually overflow the stack. For records that are created with `.new`, we have a mechanism to perform an action before the callbacks are run. I've introduced the same code path for records created with `instantiate`, and updated all code which sets inverse instances on newly loaded associations to use this block instead. Fixes #26320.
* | Merge pull request #24099 from k0kubun/preserve-readonlyRafael Mendonça França2016-08-181-1/+1
|\ \ | |/ |/| | | Preserve readonly flag only for readonly association
| * Preserve readonly flag only for readonly associationTakashi Kokubun2016-07-301-1/+1
| | | | | | | | Fixes #24093
* | Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
| |
* | applies remaining conventions across the projectXavier Noria2016-08-063-6/+0
| |
* | normalizes indentation and whitespace across the projectXavier Noria2016-08-064-117/+117
|/
* Merge pull request #18766 from yasyf/issue_17864Sean Griffin2016-02-291-8/+15
|\ | | | | | | | | Honour joining model order in `has_many :through` associations when eager loading
| * Honour the order of the joining model in a `has_many :through`Yasyf Mohamedali2015-03-022-9/+16
| | | | | | | | | | | | | | | | | | association when eager loading. Previously, eager loading a `has_many :through` association with no defined order would return the records in the natural order of the database. Now, these records will be returned in the order that the joining record is returned, in case there is a defined order there.
* | Defer Arel attribute lookup to the model classMatthew Draper2016-02-041-1/+1
| | | | | | | | | | This still isn't as separated as I'd like, but it at least moves most of the burden of alias mapping in one place.
* | Revert "Merge pull request #22486 from ↵Yves Senn2015-12-211-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | methyl/fix-includes-for-groupped-association" This reverts commit 537ac7d6ade61e95f2b70685ff2236b7de965bab, reversing changes made to 9c9c54abe08d86967efd3dcac1d65158a0ff74ea. Reason: The way we preload associations will change the meaning of GROUP BY operations. This is illustrated in the SQL generated by the added test (failing on PG): Association Load: D, [2015-12-21T12:26:07.169920 #26969] DEBUG -- : Post Load (0.7ms) SELECT "posts".* FROM "posts" LEFT JOIN comments ON comments.post_id = posts.id WHERE "posts"."author_id" = $1 GROUP BY posts.id ORDER BY SUM(comments.tags_count) [["author_id", 1]] Preload: D, [2015-12-21T12:26:07.128305 #26969] DEBUG -- : Post Load (1.3ms) SELECT "posts".* FROM "posts" LEFT JOIN comments ON comments.post_id = posts.id WHERE "posts"."author_id" IN (1, 2, 3) GROUP BY posts.id ORDER BY SUM(comments.tags_count)
* | Merge pull request #22486 from methyl/fix-includes-for-groupped-associationYves Senn2015-12-211-1/+5
|\ \ | | | | | | | | | | | | | | | | | | Pass group values when including association Conflicts: activerecord/CHANGELOG.md
| * | Pass SQL group by values when including scoped associationLucjan Suski2015-12-151-1/+5
| | | | | | | | | | | | | | | Fixes problem when added `group()` in association scope was lost in eager loaded association.
* | | Merge pull request #19423 from ↵Aaron Patterson2015-12-181-2/+7
|\ \ \ | |/ / |/| | | | | | | | yuroyoro/fix_performance_regression_of_preloading_has_many_through_relation Fix #12537 performance regression when preloading has_many_through association
| * | Read already loaded association records from association.targetTomohito Ozaki2015-04-171-2/+7
| |/ | | | | | | | | For performance, Avoid instantiate CollectionProxy. Fixes #12537
* | Never pass `nil` to `order`Sean Griffin2015-10-294-16/+7
| | | | | | | | | | | | | | | | This is part of a refactoring to make it easier to allow `order` to use sanitize like just about everything else on relation. The deleted test doesn't give any reasoning as to why passing `nil` to `order` needs to be supported, and it's rather nonsensical. I can almost see allowing an empty string being passed (though I'm tempted to just disallow it...)
* | Revert "Revert "Merge pull request #22026 from ↵Yves Senn2015-10-291-0/+4
| | | | | | | | | | | | | | | | | | akihiro17/fix-preload-association"" This reverts commit 5243946017d09afff4d70d273b0fcdfd41a4b22a. This fixes an issue with the build where tests would fail on mysql and postgresql due to different ordering.
* | Revert "Merge pull request #22026 from akihiro17/fix-preload-association"Sean Griffin2015-10-291-4/+0
| | | | | | | | | | | | | | This reverts commit 6dc6a0b17cfaf7cb6aa2b1c163b6ca141b538a8e, reversing changes made to ec94f00ba3cf250eb54fc5b7a5e3ed4b90164f34. This pull request broke the build.
* | Set `scope.reordering_value` to `true` if :reordering values are specifiedakihiro172015-10-301-0/+4
| | | | | | | | | | | | We should call `scope.order!` and set `scope.reordering_value` to `true` if :reordering values are specified Fixes #21886
* | Merge pull request #21918 from bogdan/refactor-preloaderSean Griffin2015-10-221-42/+30
|\ \ | | | | | | Refactored association preloader for performance
| * | Refactored association preloader for performanceBogdan Gusiev2015-10-221-42/+30
| | | | | | | | | | | | | | | * less arrays created * less complexity with only one level of nesting in loop
* | | 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-252-9/+5
|
* Don't access the where values hash directly in through associationsSean Griffin2015-01-251-1/+1
| | | | See 4d7a62293e148604045a5f78a9d4312e79e90d13 for the reasoning
* 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
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* 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