Bug #17632
closedreports widget fails to load if user has a filter on a table that includes a 'host_id' column
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