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.
The query could select fields based on the field the subquery was passed into
Right now I have a tendency to do this:
But I think the
Foo.queryinstance should be able to add the.select_foo_idin the passed inBar.query, so I could shorten this to something like: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.