-
Notifications
You must be signed in to change notification settings - Fork 151
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
Subqueryloader #330
base: master
Are you sure you want to change the base?
Subqueryloader #330
Conversation
Pull Request Test Coverage Report for Build 1214
💛 - Coveralls |
c21ac7d
to
de3262c
Compare
As discussed in #323, I'm not convinced that this is the complete solution. The use case in the unit test can be achieved in the latest version of Gino already. We do not need |
Why not?
Can you show me please also how can i achive the same without using |
We "do" need, not we "don't" need. 😂
|
@wwwjfy Sorry, i have read it wrong :)
what happens when there will be several models inside subquery? please take it mind when creating new use case |
Exactly. That's the cases I'd like to explore, so as to give users straightforward loader and least surprise. Thanks 😊 |
a8cfb1d
to
3f2356b
Compare
Hi @wwwjfy , how is going your research? |
Sorry for the silence! I just picked up a few issues again and will work out something this weekend. |
I created #365, trying to show what can be done in the description of this issue, for subqueries and aggregate functions. Basically, it won't be hard as long as we keep the reference of columns and/or models in a subquery and pass them to loaders. |
I don't know if this can meet your needs. If not, an example will be very helpful. |
@wwwjfy i have found the case your code does not cover - complete model loading from subquery without specifying all columns explicitly |
@jekel I could achieve this: async def test(user):
ua = User.alias()
query = select([ua]).alias()
outer_query = select([text('1'), query])
result = await outer_query.gino.load(ua).all()
assert len(result) == 1
assert result[0].id == user.id Is it what you said? |
684f7b1
to
3969c27
Compare
d3bba04
to
79e7d4c
Compare
SubqueryLoader is used to load Models from sqlalchemy aliased queries, opposite of #326 which works only on aliased gino Models
Common usecase for this loader will be - when you will have complex query with subquery, aggregated columns, etc... and you need to get result as Model object defined inside subquery
Previus discussion can be found here #323