-
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
ModelLoader Columns objects support in column loader #323
Conversation
cb0e174
to
4c0d86b
Compare
Pull Request Test Coverage Report for Build 1167
💛 - Coveralls |
I have another fix for your issue. Please check. #326 |
@wwwjfy AliasLoader works only for GINO crud operations on model, aspecially |
I'll check and make needed changes for any alias, but you get my idea, right? We can use Alias.columns to get the Column, and no need to use |
Yeah... i will try to find solution to modify AliasLoader for use on aliased query object |
Using Let me think of a valid alias use case and see how can be easily used. |
why not? |
I might be not clear. By alias not related to models, I mean like If I understand correctly, you want to be able to use both UPDATE: in a second thought, we can throw error if the passed arguments don't exist in the model. Let me think over it. |
@wwwjfy yeah, you are right, i want to be able to pass as column names strings and Column objects and i also understood that there can be problem like you said
but we can make sanity check that all columns passed belongs to the model? do i understand correctly that AliasLoader would be used like AliasLoader(aliased_query, model)? |
Unfortunately no, only object returned by Model.alias(). I'll see what can be done to improve. |
So... what do you suggest to use on aliased_query? |
For now, I'd say to use it like https://github.com/fantix/gino/pull/326/files#diff-f6247715790dd30f031c9c3d67d5814eR148, unless you have a very complex subquery, you may use |
f9b88fa
to
f3d026a
Compare
@wwwjfy i have added SubqueryLoader and checks for Column belonging to used model |
For As to pass |
I cant agree with you, it may work for simple queries where is only one model inside it, like you do in your tests, and only when using I will separate SubqueryLoader to another PR, so we can continue discussion there |
sorry, I wasn't clear. I didn't mean we shouldn't have |
f3d026a
to
03c9f90
Compare
@wwwjfy So, here is left only Columns objects support for ModelLoader |
Thanks! |
We need to support column names in ModelLoader also as Column objects, to correctly fill model fields in complex aliased queries.
Now Loader can't handle them properly, because part of model names can overlap, like
id
,name
etc... and loader iterates only over their names when filling values.