プロジェクト

全般

プロフィール

Vote #77960

完了

Add tablename to siblings query to prevent AmbiguousColumn errors

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Code cleanup/refactoring_30
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
30
version_id:
124
issue_org_id:
24296
author_id:
62070
assigned_to_id:
1
comments:
4
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

h3. Problem

I creating a plugin that show siblings for issue. And when I try to get "visible" siblings for issue I get the next error:

ActionView::Template::Error (PG::AmbiguousColumn: ERROR:  column reference "id" is ambiguous
LINE 1: ...ot_id" = $1 AND "issues"."parent_id" IS NULL AND (id <> 2) A...
                                                             ^
: SELECT "issues".* FROM "issues" INNER JOIN "projects" ON "projects"."id" = "issues"."project_id" WHERE "issues"."root_id" = $1 AND "issues"."parent_id" IS NULL AND (id <> 2) AND (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='issue_tracking'))  ORDER BY "issues"."lft" ASC):

This error can be reproduced in console by typing:

Issue.last.siblings.visible

h3. Environment

Environment:
  Redmine version                3.3.1.stable
  Ruby version                   2.3.1-p112 (2016-04-26) [x86_64-darwin16]
  Rails version                  4.2.7.1
  Environment                    development
  Database adapter               PostgreSQL
SCM:
  Subversion                     1.9.4
  Git                            2.10.1
  Filesystem

h3. Fix

Adding tablename to siblings query fix the problem.


journals

--------------------------------------------------------------------------------
Patch committed, thanks.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリCode cleanup/refactoring_30 にセット
  • 対象バージョン3.2.5_124 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0