Merge branch 'tc-fix-rails5-subquery-selfjoin' into 'master'
Work around a bug in Rails 5, where LIMIT causes trouble Closes #51729 See merge request gitlab-org/gitlab-ce!21879
This commit is contained in:
commit
ab760054ee
1 changed files with 9 additions and 1 deletions
|
@ -6,7 +6,15 @@ module Gitlab
|
|||
class << self
|
||||
def self_join(relation)
|
||||
t = relation.arel_table
|
||||
t2 = relation.arel.as('t2')
|
||||
t2 = if !Gitlab.rails5?
|
||||
relation.arel.as('t2')
|
||||
else
|
||||
# Work around a bug in Rails 5, where LIMIT causes trouble
|
||||
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/51729
|
||||
r = relation.limit(nil).arel
|
||||
r.take(relation.limit_value) if relation.limit_value
|
||||
r.as('t2')
|
||||
end
|
||||
|
||||
relation.unscoped.joins(t.join(t2).on(t[:id].eq(t2[:id])).join_sources.first)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue