aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/eager_test.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* | modernizes hash syntax in activerecordXavier Noria2016-08-061-164/+164
| |
* | applies new string literal convention in activerecord/testXavier Noria2016-08-061-128/+128
|/ | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Fix `calculate` with a string value in `from` and eager loadingRyuta Kamizono2016-06-131-0/+4
| | | | | | | | | | `construct_relation_for_association_calculations` pass a string value to `construct_join_dependency` when setting a string value in `from`. It should not pass a string value, but always `joins_values`. Related #14834, #19452. Fixes #24193.
* Exists shouldn't error when used with `includes`Sean Griffin2016-05-301-0/+1
| | | | | | | | | | | | | | | | Currently `exists?` does some hackery where it assumes that we can join onto anything that we passed to `eager_load` or `includes`, which doesn't work if we are joining onto a polymorphic association. Actually figuring out if we want to include something would require knowledge deep within the join dependency module, which is hard to pull up. The simplest solution is just to pass a flag down that says we're not actually going to try to eager load any of the data. It's not the solution I'd like, but that code really needs to be untangled before we can do much with it. This is another attempt at 6d5b1fd which should address the concerns that led to reverting it in 4ecabed.
* don't treat all associations with extensions as instance dependent.Yves Senn2016-03-031-0/+12
| | | | | | | | | | Closes #23934. This is a forward port of ac832a43b4d026dbad28fed196d2de69ec9928ac Previously the scope of all associations with extensions were wrapped in an instance dependent proc. This made it impossible to preload such associations.
* Merge pull request #18766 from yasyf/issue_17864Sean Griffin2016-02-291-0/+32
|\ | | | | | | | | 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-021-0/+32
| | | | | | | | | | | | | | | | | | 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.
* | remove args from assert_nothing_raised in testsTara Scherner de la Fuente2016-02-221-1/+1
| |
* | Revert "Merge pull request #22486 from ↵Yves Senn2015-12-211-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+17
|\ \ | | | | | | | | | | | | | | | | | | Pass group values when including association Conflicts: activerecord/CHANGELOG.md
| * | Pass SQL group by values when including scoped associationLucjan Suski2015-12-151-0/+13
| | | | | | | | | | | | | | | Fixes problem when added `group()` in association scope was lost in eager loaded association.
* | | Merge pull request #19423 from ↵Aaron Patterson2015-12-181-0/+6
|\ \ \ | |/ / |/| | | | | | | | 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-0/+6
| |/ | | | | | | | | For performance, Avoid instantiate CollectionProxy. Fixes #12537
* | Never pass `nil` to `order`Sean Griffin2015-10-291-6/+0
| | | | | | | | | | | | | | | | 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/+18
| | | | | | | | | | | | | | | | | | 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-18/+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/+18
| | | | | | | | | | | | We should call `scope.order!` and set `scope.reordering_value` to `true` if :reordering values are specified Fixes #21886
* | Fix merge conflicts for #19938Sean Griffin2015-10-201-0/+12
|\ \ | | | | | | | | | | | | This is a separate commit, as it is not just a changelog conflict. Want to point out the changes in the code
| * | Fix for activerecord join dependency instantiate bugMehmet Emin İNAÇ2015-05-041-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | use only object_id instead parent class and parent id test cases assert_equal use table name in references fix minor problems
* | | Removed mocha from Active Record Part 1Ronak Jangir2015-08-251-27/+31
| | |
* | | Merge pull request #21284 from prakashlaxkar/argument_error_testsYves Senn2015-08-181-0/+8
| | | | | | | | | | | | Correct error message in Standard American english and add a test cas…
* | | deprecate `Relation#uniq` use `Relation#distinct` instead.Yves Senn2015-05-261-1/+1
|/ / | | | | | | | | | | | | | | | | See #9683 for the reasons we switched to `distinct`. Here is the discussion that triggered the actual deprecation #20198. `uniq`, `uniq!` and `uniq_value` are still around. They will be removed in the next minor release after Rails 5.
* / Fix eager loading association using default_scope for finder methods.Santosh Wadghule2015-03-311-0/+17
|/ | | | | | - Eager loading was not working for the default_scope (class method) for 'find' & 'find_by' methods. - Fixed these by adding a new check 'respond_to?(:default_scope)'.
* Merge branch 'master' into pr/18316Mingdong Luo2015-01-311-22/+9
|\ | | | | | | | | Conflicts: activerecord/CHANGELOG.md
| * remove deprecated support to preload instance-dependent associaitons.Yves Senn2015-01-051-22/+9
| | | | | | | | Addresses https://github.com/rails/rails/commit/ed56e596a0467390011bc9d56d462539776adac1#commitcomment-9145960
* | Fix n+1 query problem when eager loading nil associations (fixes #18312)Sammy Larbi2015-01-031-0/+8
|/
* `eager_load` preserves readonly flag for associationsTakashi Kokubun2014-12-301-1/+4
|
* Fix "nonexistent" typo in testsMelissa Xie2014-12-021-2/+2
|
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-10/+10
|
* Adds preloaded_records method to NullPreloaderThorsten Ball2014-11-281-0/+8
| | | | | | | | This fixes a regression where preloading association throws an exception if one of the associations in the preloading hash doesn't exist for one record. Fixes #16070
* Fix includes on association with a scope containing joins along with conditionssiddharth@vinsol.com2014-11-211-0/+6
| | | | on the joined assoiciation
* Build fix when running in isolationArun Agrawal2014-11-141-0/+1
| | | | | `Computer` class needs to be require See #17217 for more details
* measure record instantiation time in AS::NotificationsAaron Patterson2014-10-131-0/+36
| | | | | emit an event when we instantiate AR objects so we can see how many records were instantiated and how long it took
* Fixed regression with referencing polymorphic assoc in eager-loadGodfrey Chan2014-09-051-0/+10
| | | | | | | | | | | | This is cased by 03118bc + 9b5d603. The first commit referenced the undefined local variable `column` when it should be using `reflection.type` as the lookup key. The second commit changed `build_arel` to not modify the `bind_values` in- place so we need to combine the arel's `bind_values` with the relation's when building the SQL. Fixes #16591 Related #15821 / #15892 / 7aeca50
* `preload` preserves readonly flag on associations. #15853Yves Senn2014-06-251-0/+29
| | | | | | 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`.
* Fix regression on eager loading association based on SQL query ratherLauro Caetano2014-06-031-0/+4
| | | | | | than existing column. Fixes #15480.
* Fix syntax error from 5eae77cZachary Scott2014-05-261-1/+1
|
* Move test to the proper fileRafael Mendonça França2014-05-261-0/+7
| | | | All preload tests are in the eager_test file
* Add test case for b13d260Rafael Mendonça França2014-05-261-0/+9
|
* Remove dead test code for unsupported adaptersSean Griffin2014-05-171-17/+3
|
* deprecate, join, preload, eager load of instance dependent associations.Yves Senn2014-05-101-4/+27
| | | | | | | Closes #15024. These operations happen before instances are created. The current behavior is misleading and can result in broken behavior.
* :scissors:Rafael Mendonça França2014-04-111-2/+2
|
* fix exception on polymorphic associations with predicatesSimon Woker2014-04-111-0/+8
|
* Simplify Preloader#grouped_records code.thedarkone2014-03-301-4/+4
| | | | | | The new method relies on AR::Associations::Association knowing about both reflection and a model class. AR::Base#association now raises a descriptive error when trying to access non-existent associations. Previously it would blow up with a confusing NoMethodError: undefined method `association_class' for nil:NilClass.
* Fix polymorphic preloads on NOT NULL _type columns.thedarkone2014-03-301-0/+11
| | | | Defer to Association#klass instead of having a custom/duplicate code.
* `where.not` adds `references` for `includes`.Yves Senn2014-03-171-0/+10
| | | | Closes #14406.
* passing an instance of an AR object to `find` is deprecatedAaron Patterson2014-03-131-3/+3
| | | | please pass the id of the AR object by calling `.id` on the model first.
* `includes` uses SQL parsing when String joins are involved.Yves Senn2014-02-281-0/+9
| | | | | | | | | | | | | | This is a partial revert of 22b3481ba2aa55fad1f9a5db94072312b345fb55. The current implementation of `references_eager_loaded_tables?` needs to know every table involved in the query. With the current API this is not possible without SQL parsing. While a2dab46cae35a06fd5c5500037177492a047c252 deprecated SQL parsing for `includes`. It did not issue deprecation warnings when String joins are involved. This resulted in a breaking change after the deprecated behavior was removed (22b3481ba2aa55fad1f9a5db94072312b345fb55). We will need to rethink the usage of `includes`, `preload` and `eager_load` but for now, this brings back the old *working* behavior.
* Fix that eager loading of polymorphic associations did not work with ↵David Heinemeier Hansson2013-11-141-2/+0
| | | | association empty?/any? predicates any more (there is still a problem when select is applied to a relation, or if you try association#exists? -- but its easier to work around)
* Mark broken test as pendingRafael Mendonça França2013-11-081-0/+2
| | | | This will avoid the broken window effect in our test suite