Skip to content

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

hide embedded completely if empty

ulfertsb08d4ed57362
diff --git a/lib/api/decorators/sql/hal.rb b/lib/api/decorators/sql/hal.rb
index 185f1868b42..0836121588b 100644
--- a/lib/api/decorators/sql/hal.rb
+++ b/lib/api/decorators/sql/hal.rb
@@ -154,10 +154,13 @@ module API
link[:column]
end
+ next unless representation
+
<<-SQL.squish
'#{name}', #{representation}
SQL
end
+ .flatten
.join(', ')
end
diff --git a/lib/api/decorators/sql_collection_representer.rb b/lib/api/decorators/sql_collection_representer.rb
index ce837305cda..87dc6cf944f 100644
--- a/lib/api/decorators/sql_collection_representer.rb
+++ b/lib/api/decorators/sql_collection_representer.rb
@@ -123,7 +123,7 @@ module API
representation: ->(walker_result) do
replacement = walker_result.replace_map['elements']
- replacement ? "json_agg(#{replacement})" : 'null'
+ replacement ? "json_agg(#{replacement})" : nil
end
end
end
diff --git a/spec/lib/api/v3/projects/project_sql_collection_representer_rendering_spec.rb b/spec/lib/api/v3/projects/project_sql_collection_representer_rendering_spec.rb
index 4fa365fe99b..6ba3a8ae5f5 100644
--- a/spec/lib/api/v3/projects/project_sql_collection_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/projects/project_sql_collection_representer_rendering_spec.rb
@@ -118,8 +118,6 @@ describe ::API::V3::Projects::ProjectSqlCollectionRepresenter, 'rendering' do
total: 1,
count: 1,
offset: 1,
- # TODO: remove empty embedded
- _embedded: {},
_links: {
self: {
href: "some_path?offset=1&pageSize=5&select=%2A"