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
[#60672] fix select total for project with no wps
Eric Schubert17aea283f6b2
diff --git a/lib/api/decorators/sql_collection_representer.rb b/lib/api/decorators/sql_collection_representer.rbindex 639fbb501d4..112ef2d7d71 100644--- a/lib/api/decorators/sql_collection_representer.rb+++ b/lib/api/decorators/sql_collection_representer.rb@@ -33,12 +33,24 @@ module APIclass << selfdef ctes(walker_result)+ # Currently, there does not appear to be a way to correctly transform the filter_scope into SQL+ # (e.g. by calling #to_sql) so that the extra call to the database is avoided. The main problem+ # is that LEFT JOINS added via includes are not part of the SQL generated by #to_sql.+ count = walker_result.filter_scope.count+ projection = if count == 0+ # The following processes need the projection to return a non-empty response.+ # If the count is 0, though, the projection would return nothing.+ "SELECT 1"+ else+ walker_result.projection_scope+ .limit(sql_limit(walker_result))+ .offset(sql_offset(walker_result))+ .to_sql+ end+{- projection: walker_result.projection_scope.limit(sql_limit(walker_result)).offset(sql_offset(walker_result)).to_sql,- # Currently there does not appear to be a way to correctly transform the filter_scope into sql- # (e.g. by calling #to_sql) so that the extra call to the database is avoided. The main problem- # is that LEFT JOINS added via includes are not part of the SQL generated by #to_sql.- total: "SELECT #{walker_result.filter_scope.count}"+ projection:,+ total: "SELECT #{count}"}end