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

Add support for getting attributes on has_many associations (&attributes=vms.name) #871

Open
jrafanie opened this issue Jul 24, 2020 · 2 comments

Comments

@jrafanie
Copy link
Member

Because we can't ask for a single attribute on a plural association and if we don't have an exposed virtual attribute, I think this would require us to bring back the whole collection proxy with all of their attributes (all vms with all of their real attributes) in order to get just one or two.

This doesn't work:

/api/providers?expand=resources&attributes=name,vms.name

Results in calling name on the collection proxy, resulting in the name of the collection, not an array of names for each Vm.

    "resources": [
        {
            "href": "http://localhost:3000/api/providers/4",
            "name": "REDACTED1",
            "id": "4",
            "vms": {
                "name": "Vm"
            }
        },
        {
            "href": "http://localhost:3000/api/providers/3",
            "name": "REDACTED2",
            "id": "3",
            "vms": {
                "name": "Vm"
            }
        },

Meanwhile, singular associations work:

/api/vms?expand=resources&attributes=name,hardware.cpu_sockets
    "resources": [
        {
            "href": "http://localhost:3000/api/vms/485",
            "name": "REDACTED3",
            "id": "485",
            "hardware": {
                "cpu_sockets": 1
            }
        },
        {
            "href": "http://localhost:3000/api/vms/338",
            "name": "REDACTED4",
            "id": "338",
            "hardware": {
                "cpu_sockets": 4
            }
        },

Related to #805

@kbrock
Copy link
Member

kbrock commented Sep 21, 2021

our virtual attributes only really allow you to do a single child attribute. It is because we implement them as sub queries and sql subqeries only handle a single value per row. Maybe we can do better with postgres functions to convert to sql arrays.

@miq-bot miq-bot added the stale label Feb 27, 2023
@miq-bot
Copy link
Member

miq-bot commented Feb 27, 2023

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.

@Fryguy Fryguy removed the stale label Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants