Patch #24296

Add tablename to siblings query to prevent AmbiguousColumn errors

Added by Danil Tashkinov 4 months ago. Updated 3 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Code cleanup/refactoring
Target version:3.2.5

Description

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

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

Fix

Adding tablename to siblings query fix the problem.

siblings.diff Magnifier (521 Bytes) Danil Tashkinov, 2016-11-08 13:35

Associated revisions

Revision 15958
Added by Jean-Philippe Lang 3 months ago

Add tablename to siblings query (#24296).

Patch by Danil Tashkinov.

History

#1 Updated by Go MAEDA 3 months ago

  • Target version set to Candidate for next minor release

#2 Updated by Jean-Philippe Lang 3 months ago

  • Subject changed from Add tablename to siblings query to Add tablename to siblings query to prevent AmbiguousColumn errors
  • Category set to Code cleanup/refactoring
  • Assignee set to Jean-Philippe Lang
  • Target version changed from Candidate for next minor release to 3.2.5

Patch committed, thanks.

#3 Updated by Jean-Philippe Lang 3 months ago

  • Status changed from New to Resolved

#4 Updated by Jean-Philippe Lang 3 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF