O
O
Okipniy2018-04-20 10:43:46
Redmine
Okipniy, 2018-04-20 10:43:46

Redmine 3.4 How to fix a request resulting in a 500 error in the project task list?

The error is as follows.
3 custom fields added to tasks
confbase - list type
customer - string type
issuein - list type
these fields are required.
When opening the list of tasks for a project and adding one of these fields to the display table, redmine crashes with a 500 error.
In the logs, it swears at an invalid request

Processing by IssuesController#index as HTML
  Parameters: {"utf8"=>"✓", "set_filter"=>"1", "sort"=>"id:desc", "f"=>[""], "c"=>["project", "tracker", "status", "priority", "done_ratio", "subject", "assigned_to", "created_on", "cf_1"], "group_by"=>"", "t"=>["estimated_hours", "spent_hours", ""]}
  Current user: admin (id=1)
Query::StatementInvalid: TinyTds::Error: Incorrect syntax near '.'.: EXEC sp_executesql N'SELECT custom_values.*, cv.cnt, cv.field_format FROM [custom_values] INNER JOIN
                                                (
                                                  SELECT cv.id
                                                         cv.cnt,
                                                         cv.field_format
                                                  FROM
                                                  (
                                                    SELECT cv.id,
                                                           cv_m.cnt,
                                                           cf.field_format,
                                                           case when cf.multiple = 1 and cf.acl_trim_multiple = 1 then 1 else 0 end as mlt,
                                                           ROW_NUMBER() OVER (PARTITION BY i.id, cv.custom_field_id, ORDER BY i.id, cv.custom_field_id, cv.id) as row_number
                                                    FROM custom_values cv
                                                         INNER JOIN custom_fields cf on cf.id = cv.custom_field_id
                                                         INNER JOIN issues i on i.id = cv.customized_id
                                                         INNER JOIN (SELECT COUNT(1) as cnt, cv.custom_field_id, cv.customized_id FROM custom_values cv WHERE cv.customized_type = ''Issue'' and cv.custom_field_id IN (1) and cv.customized_id IN (5093,5092,5091,5090,5089,5088,5087,5086,5085,5084,5083,5082,5081,5080,5079,5078,5077,5076,5075,5074,5073,5072,5071,4075,4074) GROUP BY cv.custom_field_id, cv.customized_id) cv_m on cv_m.custom_field_id = cf.id and cv_m.customized_id = i.id
                                                    WHERE cv.customized_type = ''Issue''
                                                      and cv.custom_field_id IN (1)
                                                      and i.id IN (5093,5092,5091,5090,5089,5088,5087,5086,5085,5084,5083,5082,5081,5080,5079,5078,5077,5076,5075,5074,5073,5072,5071,4075,4074)
                                                    ORDER BY i.id, cv.custom_field_id, cv.id
                                                  ) cv
                                                  WHERE cv.mlt = 0 OR cv.row_number <= 3
                                                ) cv on cv.id = custom_values.id  ORDER BY [custom_values].[customized_id] ASC, [custom_values].[custom_field_id] ASC, [custom_values].[id] ASC'
  Rendered common/error.html.erb within layouts/base (0.0ms)

Actually the question itself is in which file this request is formed.
System parameters
ОС Windows Server 2016 Standart 64 bit
Environment:
  Redmine version                3.4.4.stable
  Ruby version                   2.3.3-p222 (2016-11-21) [i386-mingw32]
  Rails version                  4.2.8
  Environment                    production
  Database adapter               SQLServer
SCM:
  Git                            1.9.4
  Filesystem                     
Redmine plugins:
  a_common_libs                  2.4.0
  global_roles                   2.2.1
  redmine_checklists             3.1.10

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iPahan1988, 2018-04-23
@Okipniy

O! I just solved this problem!!!!!
You need to fix the file issue_query_patch.rb which is located along the path redmine-3.4.4/plugins/a_common_libs/lib/acl/patches/models.
At the request

SELECT cv.id
                                                         cv.cnt,
                                                         cv.field_format
                                                  FROM
                                                  (
                                                    SELECT cv.id,
                                                           cv_m.cnt,
                                                           cf.field_format,
                                                           case when cf.multiple = 1 and cf.acl_trim_multiple = 1 then 1 else 0 end as mlt,
                                                           ROW_NUMBER() OVER (PARTITION BY i.id, cv.custom_field_id, ORDER BY i.id, cv.custom_field_id, cv.id) as row_number

There is not enough comma in the first select where there is SELECT cv.id
also an extra comma in the part where
OVER (PARTITION BY i.id, cv.custom_field_id, ORDER BY i.id, cv.custom_field_id, cv.id)

ORDER BY must not be preceded by a comma

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question