OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Also fix orders in subqueries
Klaus Zanders3817df82649f
diff --git a/app/models/journable/historic_active_record_relation.rb b/app/models/journable/historic_active_record_relation.rbindex eef1e59b7bd..adcc7e60ef7 100644--- a/app/models/journable/historic_active_record_relation.rb+++ b/app/models/journable/historic_active_record_relation.rb@@ -114,9 +114,9 @@ class Journable::HistoricActiveRecordRelation < ActiveRecord::Relation# Based on the previous modifications, build the algebra object.arel = relation.call_original_build_arel(aliases)+ arel = modify_where_clauses(arel)arel = modify_order_clauses(arel)- arel = modify_joins(arel)- modify_where_clauses(arel)+ modify_joins(arel)enddef call_original_build_arel(aliases = nil)@@ -384,6 +384,20 @@ class Journable::HistoricActiveRecordRelation < ActiveRecord::Relationelsif node.kind_of? Arel::Nodes::SelectStatement# A sub-select statement, we need to investigate its core, which is also a SelectCoremodify_conditions(node.instance_variable_get(:@cores).first)++ # all the orders need to be modified as well+ node.instance_variable_get(:@orders).each do |order_clause|+ if order_clause.kind_of? Arel::Nodes::SqlLiteral+ gsub_table_names_in_sql_string!(order_clause)+ elsif order_clause.expr.relation == model.arel_table+ if order_clause.expr.name == "id"+ order_clause.expr.name = "journable_id"+ order_clause.expr.relation = Journal.arel_table+ else+ order_clause.expr.relation = model.journal_class.arel_table+ end+ end+ endelsif node.kind_of? Arel::Nodes::SelectCore# We have another SelectCore, which is the main part of the select statement.# Sources are the select table (left) and all joins (right)