Project

General

Profile

Actions

Patch #24296

closed

Add tablename to siblings query to prevent AmbiguousColumn errors

Added by Danil Tashkinov about 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

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.


Files

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

Updated by Go MAEDA about 8 years ago

  • Target version set to Candidate for next minor release
Actions #2

Updated by Jean-Philippe Lang about 8 years 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.

Actions #3

Updated by Jean-Philippe Lang about 8 years ago

  • Status changed from New to Resolved
Actions #4

Updated by Jean-Philippe Lang almost 8 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF