Project

General

Profile

Bug #3122

when fact filters are added to a user, error column reference "id" is ambiguous for dashboard and fact_values

Added by m w almost 6 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Category:
Database
Target version:
Difficulty:
trivial
Triaged:
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

In 1.2.2, when fact filters are added to a user, this error is displayed when trying to view /dashboard or /fact_values

Started GET "/" for x.x.x.x at 2013-09-19 10:43:17 -0400
Processing by DashboardController#index as HTML
Rendered dashboard/_status_table.html.erb (9.3ms)
Rendered dashboard/index.html.erb within layouts/application (21.1ms)
Operation FAILED: PGError: ERROR: column reference "id" is ambiguous
LINE 1: SELECT id FROM "hosts" INNER JOIN "fact_values" ON "fact_val...
^
: SELECT id FROM "hosts" INNER JOIN "fact_values" ON "fact_values"."host_id" = "hosts"."id" WHERE "hosts"."type" IN ('Host::Managed') AND (((hosts.id = fact_values.host_id and fact_values.fact_name_id = 798 and fact_values.value = 'factname')) )
Rendered common/500.html.erb within layouts/application (6.6ms)
Completed 500 Internal Server Error in 101ms (Views: 7.9ms | ActiveRecord: 0.6ms)

Seems like same issue as http://projects.theforeman.org/issues/2579


Related issues

Related to Foreman - Bug #2579: Host groups with puppet classes triggers: column 'id' in field list is ambiguousClosed2013-05-28
Related to Foreman - Bug #5841: Foreman dashboard slow in 1.5 for non admin usersClosed2014-05-20
Blocks Foreman - Bug #2982: Non Admin user Dashboard load is very slow with a large number of mangaged nodesResolved2013-08-28
Copied to Foreman - Bug #3863: when fact filters are added to a user, error column reference "id" is ambiguous for fact_valuesResolved2013-09-19

Associated revisions

Revision 83b28745 (diff)
Added by Dmitri Dolguikh almost 6 years ago

Fixes #3122: 'column reference id is ambiguous' no longer appears on dashboard and report screens

Revision ec75f9c0 (diff)
Added by Dmitri Dolguikh almost 6 years ago

Fixes #3122: 'column reference id is ambiguous' no longer appears on dashboard and report screens

(cherry picked from commit 83b2874539b2b5469586a23b1edacbdf2a88d2ef)

History

#1 Updated by Dominic Cleal almost 6 years ago

  • Category set to Database
  • Target version set to 1.3.0
  • Difficulty set to trivial

#2 Updated by Dmitri Dolguikh almost 6 years ago

  • Status changed from New to Rejected

Can't reproduce using the latest from "develop" branch.

#3 Updated by Dominic Cleal almost 6 years ago

  • Status changed from Rejected to New

This is probably a Rails 3.2.8 issue (as used in the RPMS), as .14 and more recent versions handle the ambiguity. If we use a pluck(:id) or similar in a statement that also uses joins, we need to explicitly mention the table name. See also #2579.

Could you try on an RPM install or 3.2.8 please Dmitri?

#4 Updated by Dmitri Dolguikh almost 6 years ago

  • Assignee set to Dmitri Dolguikh

#5 Updated by Dmitri Dolguikh almost 6 years ago

  • Status changed from New to Closed

seems to be working on 3.2.8. SQL query uses table name explicitly (SELECT "hosts"."id" AS t0_r0 ... INNER JOIN "fact_values" ON "fact_values"."host_id" = "hosts"."id" ...).

#6 Updated by Dominic Cleal almost 6 years ago

  • Status changed from Closed to New
  • Target version deleted (1.3.0)

Reproduced on a 1.3.0-RC3 RPM installation:

 ActiveRecord::StatementInvalid
PGError: ERROR: column reference "id" is ambiguous LINE 1: SELECT id FROM "hosts" INNER JOIN "fact_values" ON "fact_val... ^ : SELECT id FROM "hosts" INNER JOIN "fact_values" ON "fact_values"."host_id" = "hosts"."id" WHERE "hosts"."type" IN ('Host::Managed') AND (((hosts.owner_id in (NULL) AND hosts.owner_type = 'Usergroup') OR (hosts.owner_id = 2 AND hosts.owner_type = 'User')) or (hosts.domain_id in (1)) or ((hosts.id = fact_values.host_id and fact_values.fact_name_id = 61 and fact_values.value = 'x86_64')) )
app/models/report.rb:35:in `block in '
app/helpers/dashboard_helper.rb:42:in `latest_events'
app/views/dashboard/index.html.erb:17:in `_app_views_dashboard_index_html_erb___3590133410700692552_61518440'
app/controllers/dashboard_controller.rb:6:in `index'
app/models/concerns/foreman/thread_session.rb:33:in `clear_thread' 

foreman-1.3.0-0.4.RC3.el6.noarch
ruby193-rubygem-activerecord-3.2.8-12.el6.noarch
ruby193-rubygem-pg-0.12.2-8.el6.x86_64

#7 Updated by Dmitri Dolguikh almost 6 years ago

  • Target version set to 1.15.0

#8 Updated by Dmitri Dolguikh almost 6 years ago

  • Status changed from New to Assigned

#9 Updated by Dmitri Dolguikh almost 6 years ago

  • Status changed from Assigned to Ready For Testing

#10 Updated by Dominic Cleal almost 6 years ago

  • Legacy Backlogs Release (now unused) set to 1

#11 Updated by Anonymous almost 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#12 Updated by Dominic Cleal almost 6 years ago

  • Blocks Bug #2982: Non Admin user Dashboard load is very slow with a large number of mangaged nodes added

#13 Updated by m w over 5 years ago

still broken for /fact_values
needs the same fix

#14 Updated by Dominic Cleal over 5 years ago

  • Copied to Bug #3863: when fact filters are added to a user, error column reference "id" is ambiguous for fact_values added

#15 Updated by Dominic Cleal over 5 years ago

m w wrote:

still broken for /fact_values
needs the same fix

Sorry, I missed this part of the bug report. I've copied this to #3863.

#16 Updated by Dominic Cleal over 5 years ago

  • Related to Bug #2579: Host groups with puppet classes triggers: column 'id' in field list is ambiguous added

#17 Updated by Dominic Cleal over 5 years ago

  • Related to Bug #5841: Foreman dashboard slow in 1.5 for non admin users added

Also available in: Atom PDF