Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix GuestDevice#child_device references #22670

Merged
merged 2 commits into from
Aug 22, 2023
Merged

Commits on Aug 22, 2023

  1. fix GuestDevice#child_device references

    The child_devices added unneeded scope.
    This scope pulled back all ids from the guest devices table.
    
    Since the foreign_key is added to the query, this did not do any harm.
    But it adds an unneeded constraint an unneeded query.
    
    This was introduce in ManageIQ#15371
    The way the PR was batted around, it looked like this was not an intentional side effect.
    
    Before
    ======
    
    ```ruby
    has_many :child_devices, -> { where(:parent_device_id => ids) }, :foreign_key => "parent_device_id"
    has_many :child_devices, -> { where(:parent_device_id => GuestDevice.ids) }, :foreign_key => "parent_device_id"
    
    SELECT "guest_devices".*
    FROM "guest_devices"
    WHERE "guest_devices"."parent_device_id" = 26000000000035
      AND "guest_devices"."parent_device_id" IN (26000000000032, 26000000000033, 26000000000034, 26000000000035, 26000000000036, 26000000000037, 26000000000038)
    ```
    
    After
    =====
    
    ```ruby
    has_many :child_devices, :foreign_key => "parent_device_id"
    
    SELECT "guest_devices".*
    FROM "guest_devices"
    WHERE "guest_devices"."parent_device_id" = 26000000000035
    ```
    kbrock committed Aug 22, 2023
    Configuration menu
    Copy the full SHA
    7299d1a View commit details
    Browse the repository at this point in the history
  2. GuestDevice#parent_device

    To be honest, I only added this to make rubocop happy.
    But it did feel like it was missing and made the specs a little prettier.
    kbrock committed Aug 22, 2023
    Configuration menu
    Copy the full SHA
    732039f View commit details
    Browse the repository at this point in the history