Vote #77301
未完了Group by custom field of type text
0%
説明
We are unable to create a custom field of type text. Group by work for custom fields of type integer etc but "text" format ones cannot be gorup by.
journals
--------------------------------------------------------------------------------
This seems to work already, at least in Planio hosted version. Maybe they contribute with a patch if that's the case.
What I see is that we cannot group by a field that is not for "all projects". Does it make sense?
--------------------------------------------------------------------------------
Bruno Medeiros wrote:
> This seems to work already, at least in Planio hosted version. Maybe they contribute with a patch if that's the case.
This is something that we would contribute if we were to work on it, but I am not aware this is possible on Planio. Could you double-check that you can group an issue list by a custom field of type "text"?
> What I see is that we cannot group by a field that is not for "all projects". Does it make sense?
I am able to group by a custom field that is defined on only one project in that project's issue list. Do you maybe mean that you can only use custom fields defined as "for all projects" to group by on the global issue list?
--------------------------------------------------------------------------------
This indeed could be achieved by patching, see patch below.
This seem to work for me with minor limitation,i.e. string after n in the example below(255) char will be truncated
<pre>
diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb
index fade7c2..ad9041c 100644
--- a/lib/redmine/field_format.rb
+++ b/lib/redmine/field_format.rb
@@ -387,6 +387,10 @@ module Redmine
value.to_s
end
end
+
+ def group_statement(custom_field)
+ "CAST(cf_#{custom_field.id}.value AS char(255))"
+ end
end
class TextFormat < Unbounded
</pre>
<pre>
Environment:
Redmine version 3.4.2.stable
Ruby version 2.4.2-p198 (2017-09-14) [x86_64-linux]
Rails version 4.2.8
Environment development
Database adapter Mysql2 (mariadb)
</pre>
--------------------------------------------------------------------------------