Bug 1402611

Summary: dashboard sql error when select '~' Like option in user role filter
Product: Red Hat Satellite Reporter: Ashfaqur Rahaman <arahaman>
Component: DashboardAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.4CC: bbuckingham, ggatward, jcallaha, ohadlevy, tbrisker
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-12 13:37:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ashfaqur Rahaman 2016-12-08 00:08:56 UTC
Description of problem:

Dashboard is showing SQL error if we select '~' like option in User role "Host" filter. 

Version-Release number of selected component (if applicable):
Satellite 6.2.4

How reproducible:
100% 

Steps to Reproduce:

- Configure a Host Collection (lets call it 'Test Hostcollection 1')
- Add at least one host to 'Test Hostcollection 1'

- Create role "MyRole1" with below filters: 

1. Miscellaneous: access_dashboard, access_settings, view_plugins, view_statistics, view_tasks 
   Filter : None

2. Activation Keys : view_activation_keys 
   Filter: name ~ ak_capsule_provision 	

3. Content Host : edit_content_hosts, view_content_hosts, 
   Filter: host_collection ~ "Test Hostcollection 1" 	

4. Fact value: view_facts 
   Filter: none 	

5. Host : edit_hosts, build_hosts, view_hosts
   Filter: host_collection ~ "Test Hostcollection 1"  

6. Organization : view_organizations, view_subscriptions
   Filter : none

7. Product and Repositories: view_products
   Filter: none

- Create a user myUser1

- Assign the role myRole to myUser1

- Login as myUser1 and open the dashboard 

Actual results:

It gives the below error in dashboard :

---- 
PG::Error: ERROR: missing FROM-clause entry for table "katello_host_collections"
 LINE 1:
 ...id" IN (1) AND "hosts"."location_id" IN (2) AND (("katello_h... ^ :
 SELECT COUNT(count_column)
 FROM
 (SELECT 1 AS count_column FROM "katello_errata"
          INNER JOIN "katello_content_facet_errata" ON "katello_content_facet_errata"."erratum_id" = "katello_errata"."id" 
          INNER JOIN "katello_content_facets" ON "katello_content_facets"."id" = "katello_content_facet_errata"."content_facet_id"
               WHERE "katello_content_facets"."host_id" IN
                       (SELECT "hosts"."id" FROM "hosts" WHERE "hosts"."type"
                           IN ('Host::Managed') AND "hosts"."organization_id"
                           IN (1) AND "hosts"."location_id" IN (2) AND (("katello_host_collections"."name" ILIKE '%Test Hostcollection 1%'))) LIMIT 6)
                      subquery_for_count
----

Expected results:

It should show the dashboard

Additional info: 

There is a work around for this. In step 5, if we use '=' instead of '~' in "Host" filter, it works. 

---
5. Host : edit_hosts, build_hosts, view_hosts
   Filter: host_collection = "Test Hostcollection 1"  
---

Comment 3 Tomer Brisker 2016-12-12 13:37:53 UTC
Looks like this has been fixed already in https://bugzilla.redhat.com/show_bug.cgi?id=1232877 which should land in 6.3.
Marking as duplicate.

*** This bug has been marked as a duplicate of bug 1232877 ***