maxrossello / redmine_extended_watchers

Grant additional issue and project view permissions to watcher users
GNU General Public License v3.0
44 stars 20 forks source link

Query::StatementInvalid (PG::SyntaxError: ERROR: subquery has too many columns #44

Closed KiYiul closed 1 year ago

KiYiul commented 1 year ago

Redmine 4.2.1.stable DMSF plugin 3.0.5 redmine_extended_watchers plugin 4.2.1

The Korean character in blow log translation,

from: Query::StatementInvalid (PG::SyntaxError: 오류:  subquery 에가 너무 많은 칼럼을 가집니다
to: Query::StatementInvalid (PG::SyntaxError: ERROR:  subquery has too many columns

To fix that issue, I was already install again redmine_dsmf plugin that v3.0.5 but the issue not resolved. and I realize that the issue caused by redmine_extended_watchers plugin. When the plugin installed and configure to Extended or Protected mode, that 500 error occurred. and on Default mode, the issue not occrred.

I don't understand why "subquery has too many columns" error occurred when using redmine_dmsf plugin only set Extended or Protected mode that redmine_extended_watchers plugin.

I know that it is not only redmine_extended_watcher plugin problem, However can you provide some advise for me?

Completed 500 Internal Server Error in 45ms (ActiveRecord: 16.7ms)

Query::StatementInvalid (PG::SyntaxError: 오류:  subquery 에가 너무 많은 칼럼을 가집니다
LINE 41: ...ts" WHERE (( projects.status <> 9 OR (projects.id IN (SELECT...
                                                              ^
: SELECT COUNT(*) FROM ( (SELECT
        dmsf_folders.id AS id,
        dmsf_folders.project_id AS project_id,
        CAST(NULL AS integer) AS revision_id,
        dmsf_folders.title AS title,
        NULL AS filename,
        CAST(NULL AS integer) AS size,
        dmsf_folders.updated_at AS updated,
        CAST(NULL AS integer) AS major_version,
        CAST(NULL AS integer) AS minor_version,
        CAST(NULL AS integer) AS patch_version,
        CAST(NULL AS integer) AS workflow,
        CAST(NULL AS integer) AS workflow_id,
        users.firstname AS firstname,
        users.lastname AS lastname,
        users.id AS author,
        'folder' AS type,
        dmsf_folders.deleted AS deleted,
        'DmsfFolder' AS customized_type,
        dmsf_folders.id AS customized_id,
        1 AS sort FROM "dmsf_folders" LEFT JOIN users ON dmsf_folders.user_id = users.id WHERE (1=0)) UNION ALL (SELECT
      projects.id AS id,
      projects.id AS project_id,
      CAST(NULL AS integer) AS revision_id,
      projects.name AS title,
      projects.identifier AS filename,
      CAST(NULL AS integer) AS size,
      projects.updated_on AS updated,
      CAST(NULL AS integer) AS major_version,
      CAST(NULL AS integer) AS minor_version,
      CAST(NULL AS integer) AS patch_version,
      CAST(NULL AS integer) AS workflow,
      CAST(NULL AS integer) AS workflow_id,
      '' AS firstname,
      '' AS lastname,
      CAST(NULL AS integer) AS author,
      'project' AS type,
      CAST(0 AS integer) AS deleted,
      '' as customized_type,
      0 as customized_id,
      0 AS sort FROM "projects" WHERE (( projects.status <> 9 OR (projects.id IN (SELECT
      projects.id AS id,
      projects.id AS project_id,
      CAST(NULL AS integer) AS revision_id,
      projects.name AS title,
      projects.identifier AS filename,
      CAST(NULL AS integer) AS size,
      projects.updated_on AS updated,
      CAST(NULL AS integer) AS major_version,
      CAST(NULL AS integer) AS minor_version,
      CAST(NULL AS integer) AS patch_version,
      CAST(NULL AS integer) AS workflow,
      CAST(NULL AS integer) AS workflow_id,
      '' AS firstname,
      '' AS lastname,
      CAST(NULL AS integer) AS author,
      'project' AS type,
      CAST(0 AS integer) AS deleted,
      '' as customized_type,
      0 as customized_id,
      0 AS sort, "projects"."id" FROM "projects" INNER JOIN "issues" ON "issues"."project_id" = "projects"."id" WHERE (( projects.status <> 9 AND EXISTS (SELECT 1 AS one FROM enabled_modules em WHERE em.project_id = projects.id AND em.name='issue_tracking') OR ( (issues.id IN (SELECT "issues"."id" FROM "issues" INNER JOIN "watchers" ON "watchers"."watchable_id" = "issues"."id" AND "watchers"."watchable_type" = 'Issue' WHERE "watchers"."user_id" IN (2966, 11585, 2968, 2969, 10646, 11346, 10838, 10898, 10900, 12179, 12611))) AND ( 1=1 )) ) ))) )) AND "projects"."parent_id" IS NULL) ) "dmsf_folders"):

plugins/redmine_dmsf/app/models/dmsf_query.rb:101:in `rescue in dmsf_count'
plugins/redmine_dmsf/app/models/dmsf_query.rb:98:in `dmsf_count'
plugins/redmine_dmsf/app/controllers/dmsf_controller.rb:94:in `block (2 levels) in show'
plugins/redmine_dmsf/app/controllers/dmsf_controller.rb:92:in `show'
plugins/redmine_dmsf/app/controllers/dmsf_controller.rb:74:in `index'
plugins/redmine_reporting/lib/redmine_reporting/sweeper.rb:23:in `around'
plugins/redmine_reporting/lib/redmine_reporting/sweeper.rb:23:in `around'
lib/redmine/sudo_mode.rb:61:in `sudo_mode'
plugins/redmine_dmsf/lib/redmine_dmsf/webdav/custom_middleware.rb:54:i
maxrossello commented 1 year ago

I believe that the extended_watcher's modified Project.allowed_to_condition(), which returns a string containing some SQL statements, just does not fit well into some dmsf query. Maybe dmsf makes some assumption on the structure of this chunk of SQL based on plain Redmine's returned string.

I'm afraid it would take some effort to solve this incompatibility. One chance would be to try to shift to Redmine 5.0, where both plugins could have beneficial changes, but I cannot guarantee

KiYiul commented 1 year ago

Unfortunately, I have not a plan of upgrade to Redmine 5.0. As my tested on Redmine 5.0, some plugin which used currently, is not compatibility for Rednine 5.0

Our organization really need that feature of redmine_extended_watchers and dmsf plugin on current version of Redmine 4.2.1.

Can I get some help on this issue kindly?

maxrossello commented 1 year ago

I'm sorry but the little time I can dedicate to Redmine is focused on maintaining the plugin set supported by https://github.com/maxrossello/redmine_testsuites, which aims to ensure full testability of compatible plugins.

DMSF is a very interesting plugin, but there's something else that, if I had enough time, I would support first. Of course I can take in consideration and make a review of any third party contribution adopting the same test approach.