Skip to content

Query subqueries should be able to select the correct fields #214

@Jaymon

Description

@Jaymon

The query could select fields based on the field the subquery was passed into

Right now I have a tendency to do this:

        await Foo.query.eq_id(
            Bar.query
            .select_foo_id()
            .eq_baz(value)
        ).one()

But I think the Foo.query instance should be able to add the .select_foo_id in the passed in Bar.query, so I could shorten this to something like:

        await Foo.query.eq_id(Bar.query.eq_baz(value)).one()

The algo would be check if the passed in subquery already has selected fields, if it does then don't do anything. If it doesn't, then get the orm of the wrapping query and find the matching field in the subquery's orm, then select the field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions