Bug #17632

reports widget fails to load if user has a filter on a table that includes a 'host_id' column

Added by Tomer Brisker 3 months ago. Updated 3 months ago.

Status:Closed
Priority:Normal
Assigned To:Tomer Brisker
Category:Dashboard
Target version:Team Daniel - iteration 8
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman/pull/4102
Story points-
Velocity based estimate-
Release1.14.1Release relationshipAuto

Description

ActiveRecord::StatementInvalid: PG::AmbiguousColumn: ERROR: column reference "host_id" is ambiguous
LINE 1: ...ts"."location_id" = '2'))) AND (status <> 0) AND (host_id in...
^
SELECT 1 AS one FROM "reports" INNER JOIN "hosts" ON "hosts"."id" = "reports"."host_id" AND "hosts"."type" IN ('Host::Managed') AND "hosts"."organization_id" = 1 AND "hosts"."location_id" = 2 INNER JOIN "katello_host_collection_hosts" ON "katello_host_collection_hosts"."host_id" = "hosts"."id" INNER JOIN "katello_host_collections" ON "katello_host_collections"."id" = "katello_host_collection_hosts"."host_collection_id" WHERE "reports"."type" IN ('ConfigReport') AND (1=0) AND ((("katello_host_collections"."name" ILIKE '%h%') AND ("hosts"."organization_id" = '1') AND ("hosts"."location_id" = '2'))) AND (status <> 0) AND (host_id in (SELECT "hosts"."id" FROM "hosts" LEFT OUTER JOIN "katello_host_collection_hosts" ON "katello_host_collection_hosts"."host_id" = "hosts"."id" LEFT OUTER JOIN "katello_host_collections" ON "katello_host_collections"."id" = "katello_host_collection_hosts"."host_collection_id" WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."organization_id" = 1 AND "hosts"."location_id" = 2 AND ((("katello_host_collections"."name" ILIKE '%h%') AND ("hosts"."organization_id" = '1') AND ("hosts"."location_id" = '2'))))) AND (("reports"."reported_at" >= '2016-12-06')) LIMIT 1

Associated revisions

Revision 25b627e7
Added by Tomer Brisker 3 months ago

Fixes #17632 - Reports widget will not fail on ambiguous filter

A user with a filter on a joined table that has a host_id column (such
as nics for example) will cause the report widget to break due to an
ambiguous column name. This fix makes sure the columns use the table
name and are correctly quoted.

History

#1 Updated by The Foreman Bot 3 months ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4102 added

#2 Updated by Daniel Lobato Garcia 3 months ago

  • Target version set to Team Daniel - iteration 6

#3 Updated by Anonymous 3 months ago

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

#4 Updated by Dominic Cleal 3 months ago

  • Release set to 1.14.1

#5 Updated by Daniel Lobato Garcia 3 months ago

  • Target version changed from Team Daniel - iteration 6 to Team Daniel - iteration 8

Also available in: Atom PDF