Bug 1375195

Summary: VirtualDelegate: Fix foreign key for belongs_to
Product: Red Hat CloudForms Management Engine Reporter: Satoe Imaishi <simaishi>
Component: PerformanceAssignee: Keenan Brock <kbrock>
Status: CLOSED CURRENTRELEASE QA Contact: Pradeep Kumar Surisetty <psuriset>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.7.0CC: arcsharm, cpelland, dmetzger, jhardy, obarenbo
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.7.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1375206 (view as bug list) Environment:
Last Closed: 2016-12-21 11:48:11 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:
Bug Depends On:    
Bug Blocks: 1375206    

Description Satoe Imaishi 2016-09-12 13:14:36 UTC
From PR: https://github.com/ManageIQ/manageiq/pull/10717

We are using delegates more and more.
Found a few bugs with edge cases:

1. When delegating to an association that has a belongs_to, and the foreign key is non-standard, then it got the foreign key wrong. Example: belongs_to :ems_owner, :class_name => 'User' had a foreign key of user_id instead of ems_owner_id.

2. When delegating to a self referring reference, it was not returning records. Example: TestClass.belongs_to :parent, :class_name => "TestClass"

3. Test was accessing postgres due to changes in active record establish_connection. For some reason, this is only an issue when adding a has_one relation.

These changes are necessary to add delegation for ems_owner and improve performance of the vms screen.

Comment 4 Archit Sharma 2016-12-21 11:41:34 UTC
This BZ has an associated PR #10717 which is within the same context as PR #10704. Refer https://bugzilla.redhat.com/show_bug.cgi?id=1375348#c5 for further context.