Project

General

Profile

Actions

Bug #21947

closed

host scopes allow ambiguous column name

Added by Timo Goebel over 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Dashboard
Target version:
Difficulty:
trivial
Triaged:
Fixed in Releases:
Found in Releases:

Description

The host scopes recent & out_of_sync allow a sql generathion with an ambiguous column name when the host has a facet with a "last_report" column and scoped search is used.

Can be reproduced by searching for something on the dashboard and having a plugin (Omaha) installed, that has a facet with a "last_report" column.

ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: last_report: SELECT COUNT(DISTINCT "hosts"."id") FROM "hosts" LEFT OUTER JOIN "host_status" ON "host_status"."host_id" = "hosts"."id" LEFT OUTER JOIN "models" ON "models"."id" = "hosts"."model_id" LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "hosts"."hostgroup_id" AND (hostgroups.id IN (1,2,3)) LEFT OUTER JOIN "nics" ON "nics"."host_id" = "hosts"."id" AND "nics"."primary" = ? LEFT OUTER JOIN "domains" ON "domains"."id" = "nics"."domain_id" AND (domains.id IN (1,3,4)) LEFT OUTER JOIN "realms" ON "realms"."id" = "hosts"."realm_id" AND (realms.id IN (1)) LEFT OUTER JOIN "environments" ON "environments"."id" = "hosts"."environment_id" AND (1=0) LEFT OUTER JOIN "architectures" ON "architectures"."id" = "hosts"."architecture_id" LEFT OUTER JOIN "compute_resources" ON "compute_resources"."id" = "hosts"."compute_resource_id" AND (compute_resources.id IN (4,5)) LEFT OUTER JOIN "images" ON "images"."id" = "hosts"."image_id" LEFT OUTER JOIN "operatingsystems" ON "operatingsystems"."id" = "hosts"."operatingsystem_id" LEFT OUTER JOIN "nics" "primary_interfaces_hosts" ON "primary_interfaces_hosts"."host_id" = "hosts"."id" AND "primary_interfaces_hosts"."primary" = ? LEFT OUTER JOIN "nics" "interfaces_hosts" ON "interfaces_hosts"."host_id" = "hosts"."id" LEFT OUTER JOIN "nics" "primary_interfaces_hosts_join" ON "primary_interfaces_hosts_join"."host_id" = "hosts"."id" AND "primary_interfaces_hosts_join"."primary" = ? LEFT OUTER JOIN "subnets" ON "subnets"."id" = "primary_interfaces_hosts_join"."subnet_id" AND "subnets"."type" = ? AND (subnets.id IN (1,6,11)) LEFT OUTER JOIN "nics" "primary_interfaces_hosts_join_2" ON "primary_interfaces_hosts_join_2"."host_id" = "hosts"."id" AND "primary_interfaces_hosts_join_2"."primary" = ? LEFT OUTER JOIN "subnets" "subnet6s_hosts" ON "subnet6s_hosts"."id" = "primary_interfaces_hosts_join_2"."subnet6_id" AND "subnet6s_hosts"."type" = ? AND (subnets.id IN (1,6,11)) LEFT OUTER JOIN "nics" "provision_interfaces_hosts" ON "provision_interfaces_hosts"."host_id" = "hosts"."id" AND "provision_interfaces_hosts"."provision" = ? LEFT OUTER JOIN "omaha_facets" ON "omaha_facets"."host_id" = "hosts"."id" LEFT OUTER JOIN "omaha_groups" ON "omaha_groups"."id" = "omaha_facets"."omaha_group_id" LEFT OUTER JOIN "discovery_rules" ON "discovery_rules"."id" = "hosts"."discovery_rule_id" AND (1=0) WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."organization_id" = 2 AND (("hosts"."name" LIKE '%infra%' OR "hosts"."comment" LIKE '%infra%' OR "models"."name" LIKE '%infra%' OR "hostgroups"."name" LIKE '%infra%' OR "hostgroups"."title" LIKE '%infra%' OR "hostgroups"."title" LIKE '%infra%' OR "domains"."name" LIKE '%infra%' OR "realms"."name" LIKE '%infra%' OR "environments"."name" LIKE '%infra%' OR "architectures"."name" LIKE '%infra%' OR "compute_resources"."name" LIKE '%infra%' OR "images"."name" LIKE '%infra%' OR "operatingsystems"."name" LIKE '%infra%' OR "operatingsystems"."description" LIKE '%infra%' OR "operatingsystems"."title" LIKE '%infra%' OR "operatingsystems"."major" LIKE '%infra%' OR "operatingsystems"."minor" LIKE '%infra%' OR "nics"."ip" LIKE '%infra%' OR "nics"."ip" LIKE '%infra%' OR "nics"."mac" LIKE '%infra%' OR "subnets"."network" LIKE '%infra%' OR "subnets"."name" LIKE '%infra%' OR "subnets"."network" LIKE '%infra%' OR "subnets"."name" LIKE '%infra%' OR "hosts"."uuid" LIKE '%infra%' OR "nics"."mac" LIKE '%infra%' OR "operatingsystems"."name" LIKE '%infra%' OR "operatingsystems"."description" LIKE '%infra%' OR "operatingsystems"."title" LIKE '%infra%' OR "operatingsystems"."major" LIKE '%infra%' OR "operatingsystems"."minor" LIKE '%infra%' OR "omaha_groups"."name" LIKE '%infra%' OR "discovery_rules"."name" LIKE '%infra%')) AND (last_report > '2017-12-12 12:01:21.995871') AND (host_status.type = 'HostStatus::ConfigurationStatus') AND ((host_status.status > 0) and (
   ((host_status.status >> 12 & 63) != 0) or
   ((host_status.status >> 18 & 63) != 0)
))
Actions #1

Updated by The Foreman Bot over 6 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5072 added
Actions #2

Updated by Tomer Brisker over 6 years ago

  • translation missing: en.field_release set to 296
Actions #3

Updated by Timo Goebel over 6 years ago

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

Also available in: Atom PDF