Rails5 fix arel from in mysql_median_datetime_sql

This commit is contained in:
Jasper Maes 2018-06-26 00:25:21 +02:00
parent 0139c221e4
commit faf94535fb
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
title: Rails5 fix arel from in mysql_median_datetime_sql
merge_request: 20167
author: Jasper Maes
type: fixed

View file

@ -33,7 +33,13 @@ module Gitlab
end
def mysql_median_datetime_sql(arel_table, query_so_far, column_sym)
query = arel_table
arel_from = if Gitlab.rails5?
arel_table.from
else
arel_table
end
query = arel_from
.from(arel_table.project(Arel.sql('*')).order(arel_table[column_sym]).as(arel_table.table_name))
.project(average([arel_table[column_sym]], 'median'))
.where(