aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/inner_join_association_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Deduplicate joins valuesRyuta Kamizono2019-08-021-0/+10
| | | | | | | | | #36805 have one possible regression that failing deduplication if `joins_values` have complex order (e.g. `joins_values = [join_node_a, :comments, :tags, join_node_a]`). This fixes the deduplication to take it in the first phase before grouping.
* Preserve user supplied joins order as much as possibleRyuta Kamizono2019-07-301-8/+29
| | | | | | | | | | | | | | Currently, string joins are always applied as last joins part, and Arel join nodes are always applied as leading joins part (since #36304), it makes people struggled to preserve user supplied joins order. To mitigate this problem, preserve the order of string joins and Arel join nodes either before or after of association joins. Fixes #36761. Fixes #34328. Fixes #24281. Fixes #12953.
* Stash `left_joins` into `joins` to deduplicate redundant LEFT JOINRyuta Kamizono2019-04-051-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Originally the `JoinDependency` has the deduplication for eager loading (LEFT JOIN). This re-uses that deduplication for `left_joins`. And also, This makes left join order into part of joins, i.e.: Before: ``` association joins -> stash joins (eager loading, etc) -> string joins -> left joins ``` After: ``` association joins -> stash joins (eager loading, left joins, etc) -> string joins ``` Now string joins are able to refer left joins. Fixes #34325. Fixes #34332. Fixes #34536.
* Fix `CustomCops/AssertNot` to allow it to have failure messageRyuta Kamizono2018-05-131-3/+3
| | | | Follow up of #32605.
* Use assert_empty and assert_not_emptyDaniel Colson2018-01-251-6/+6
|
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-6/+6
|
* Ensure associations doesn't table name collide with aliased joinsRyuta Kamizono2017-10-241-0/+8
| | | | | | Currently alias tracker only refer a table name, doesn't respect an alias name. Should use `join.left.name` rather than `join.left.table_name`.
* Fix duplicate aliases when using both INNER/LEFT JOINsRyuta Kamizono2017-10-231-0/+5
| | | | | | | | It should be shared the count of alias tracking in both INNER/LEFT JOINs to avoid duplicate aliases. Fixes #30504. Closes #30410.
* Ensure associations doesn't table name collide with string joinsRyuta Kamizono2017-10-231-0/+5
| | | | | Currently we have no test for alias tracking with string joins. I've add test case for that to catch a future regression.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Restore `fixtures :author_addresses`Ryuta Kamizono2017-04-271-1/+1
| | | | | This change reverted in eac6f369 but it is needed for data integrity. See #25328.
* Revert "Merge pull request #27636 from ↵Rafael Mendonça França2017-04-261-1/+1
| | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privilege-take-2" This reverts commit c1faca6333abe4b938b98fedc8d1f47b88209ecf, reversing changes made to 8c658a0ecc7f2b5fc015d424baf9edf6f3eb2b0b. See https://github.com/rails/rails/pull/27636#issuecomment-297534129
* Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2017-03-261-1/+1
| | | | | | | | | | | | | | | privileges (take 2) Re-create https://github.com/rails/rails/pull/21233 eeac6151a5 was reverted (127509c071b4) because it breaks tests. ---------------- ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* Revert "Merge pull request #21233 from ↵Rafael Mendonça França2017-01-031-1/+1
| | | | | | | | | | mtsmfm/disable-referential-integrity-without-superuser-privileges" This reverts commit eeac6151a55cb7d5f799e1ae33aa64a839cbc3aa, reversing changes made to 5c40239d3104543e70508360d27584a3e4dc5baf. Reason: Broke the isolated tests. https://travis-ci.org/rails/rails/builds/188721346
* Use `SET CONSTRAINTS` for `disable_referential_integrity` without superuser ↵Fumiaki MATSUSHIMA2016-12-031-1/+1
| | | | | | | | | privileges ref: 72c1557254 - We must use `authors` fixture with `author_addresses` because of its foreign key constraint. - Tests require PostgreSQL >= 9.4.2 because it had a bug about `ALTER CONSTRAINTS` and fixed in 9.4.2.
* Add three new rubocop rulesRafael Mendonça França2016-08-161-7/+7
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* modernizes hash syntax in activerecordXavier Noria2016-08-061-5/+5
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-18/+18
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* systematic revision of =~ usage in ARXavier Noria2016-07-231-1/+1
| | | | | Where appropriatei, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with?
* Fix "nonexistent" typo in testsMelissa Xie2014-12-021-1/+1
|
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* WIP: pass existing joins to construct_join_dependencyMatt Jones2014-05-161-0/+10
|
* Pass a base relation to build_default_scope when joiningMatt Jones2014-02-211-0/+9
| | | | | This allows the default scope to be built using the current table alias. Resolves #12770
* Remove method redefined warnings for test suiteMatthias Zirnstein2014-01-051-1/+1
| | | | | | | | | | | | | | | | | has_many definitions with "name" as singular and as plural e.g. has_many :welcome_posts_with_comment has_many :welcome_posts_with_comments Ruby mentions it with: lib/active_record/associations/builder/collection_association.rb:65: warning: method redefined; discarding old welcome_posts_with_comment_ids lib/active_record/associations/builder/collection_association.rb:65: warning: previous definition of welcome_posts_with_comment_ids was here lib/active_record/associations/builder/collection_association.rb:75: warning: method redefined; discarding old welcome_posts_with_comment_ids= lib/active_record/associations/builder/collection_association.rb:75: warning: previous definition of welcome_posts_with_comment_ids= was here
* Fix that eager loading of polymorphic associations did not work with ↵David Heinemeier Hansson2013-11-141-1/+1
| | | | 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)
* Collapse where constraints to one where constraintPaul Nikitochkin2013-09-131-0/+5
| | | | | | | In order to remove duplication with joining arel where constraints with `AND`, all constraints on `build_arel` are collapsed into one head node: `Arel::Nodes::And` Closes: #11963
* Apply default scope when joining associations.Jon Leighton2013-06-281-0/+8
| | | | | | | | | | | | | | | | | | | For example: class Post < ActiveRecord::Base default_scope -> { where published: true } end class Comment belongs_to :post end When calling `Comment.join(:post)`, we expect to receive only comments on published posts, since that is the default scope for posts. Before this change, the default scope from `Post` was not applied, so we'd get comments on unpublished posts.
* `implicit_readonly` is being removed in favor of calling `readonly` explicitlyYves Senn2013-05-271-4/+4
|
* Deprecate the `:distinct` option for `Relation#count`.Yves Senn2013-03-151-1/+1
| | | | | | | We moved more and more away from passing options to finder / calculation methods. The `:distinct` option in `#count` was one of the remaining places. Since we can now combine `Relation#distinct` with `Relation#count` the option is no longer necessary and can be deprecated.
* Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-271-4/+4
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* remove deprecate #calculate callsJon Leighton2012-04-261-3/+3
|
* Revert "Deprecate implicit eager loading. Closes #950."Jon Leighton2012-01-161-1/+1
| | | | This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
* get rid of using instance_variable_names method from ASSergey Nartimov2012-01-071-1/+1
| | | | | - instance_variables return symbols in 1.9 - there is instance_variable_defined? method
* Deprecate implicit eager loading. Closes #950.Jon Leighton2011-12-291-1/+1
|
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* Fixed InnerJoinAssociationTest. Need to load essays fixture.Arun Agrawal2011-05-171-1/+1
|
* Add missing requiresSantiago Pastorino2011-05-111-0/+1
|
* Add a test for outer joins with conditions where value IS NULLErnie Miller2011-05-051-0/+5
|
* Add join conditions to JOIN clause, not WHEREErnie Miller2011-05-051-0/+6
|
* Add missing requireSantiago Pastorino2011-02-131-0/+1
|
* Fix table name collision due to incorrect alias count on certain joins.Ernie Miller2011-02-121-0/+7
| | | | | | [#6423 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* fixing whitespace errorsAaron Patterson2010-12-161-4/+4
|
* Add some tests for functionality in JoinAssociation which already exists but ↵Jon Leighton2010-10-131-1/+23
| | | | was previously untested
* cleaning up a bunch of parse time warnings in AR [#4186 state:resolved]Aaron Patterson2010-03-151-2/+2
| | | | Signed-off-by: wycats <wycats@gmail.com>
* Make scopes use relations under the hoodPratik Naik2010-01-161-28/+0
|
* Oops. Remove debug information inside a test from the previous commitPratik Naik2009-12-291-2/+0
|
* Migrate all the calculation methods to RelationPratik Naik2009-12-291-0/+2
|