diff options
author | Chalo Fernandez <chalofa@gmail.com> | 2018-06-06 02:41:13 -0500 |
---|---|---|
committer | Chalo Fernandez <chalofa@gmail.com> | 2018-06-06 02:43:46 -0500 |
commit | fd689d9fb119ddababae55da40004815f7c4b32d (patch) | |
tree | 2cc95af76b3d5b6a6e75d668b82772dd7e3bcdc3 /railties | |
parent | d0d3e964920602aa710507f6717010d852e37c86 (diff) | |
download | rails-fd689d9fb119ddababae55da40004815f7c4b32d.tar.gz rails-fd689d9fb119ddababae55da40004815f7c4b32d.tar.bz2 rails-fd689d9fb119ddababae55da40004815f7c4b32d.zip |
Child joins should be aliased when merging relations
Rails 5.2 does not alias child joins, causing an error about duplicated table/fields:
Example:
Using some code like:
`Post.joins(:author, :categorizations).merge(Author.select(:id)).merge(Categorization.joins(:author))`
*Before this fix:*
`
SELECT ... FROM "posts" INNER JOIN "authors" ON ... INNER JOIN "authors" ON ...
`
*After this fix:*
`
SELECT ... FROM "posts" INNER JOIN "authors" ON ... INNER JOIN "authors" "authors_categorizations" ON ...
`
Before 5.2, Rails aliased the joins, but wrongfully transformed them into a LEFT OUTER JOIN.
This fix will keep them as INNER JOINS, but make sure child joins are aliased, to avoid errors.
Diffstat (limited to 'railties')
0 files changed, 0 insertions, 0 deletions