-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: add opt-in outer default load option to model REST API #1971
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1971 +/- ##
=======================================
Coverage 78.12% 78.13%
=======================================
Files 71 71
Lines 8609 8612 +3
=======================================
+ Hits 6726 6729 +3
Misses 1883 1883
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
if getattr(item, file_col): | ||
fm = FileManager() | ||
fm.delete_file(getattr(item, file_col)) | ||
if self.is_file(file_col) and getattr(item, file_col): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve readability
if not getattr(default, "is_scalar", True): | ||
return None | ||
return value | ||
if default is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve readability
if (not self.is_pk(col_name)) and (not self.is_fk(col_name)): | ||
ret_lst.append(col_name) | ||
return ret_lst | ||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a list comprehension
) -> Query: | ||
if not select_columns: | ||
return query | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
took the chance to improve readability also
Description
This PR makes the default load on outer joins, which was added in this PR: #1961, an opt-in feature that can be enabled or disabled independently for get list and get item endpoints on
ModelRestApi
.new attrs on
ModelRestApi
:show_outer_default_load = False
list_outer_default_load = False
These will control the type of outer joins that are performed, by default nothing changes, but setting these to True will make the outer joins default to lazy loading or whatever is defined on the model relation:
https://docs.sqlalchemy.org/en/14/orm/loading_relationships.html#sqlalchemy.orm.defaultload
ADDITIONAL INFORMATION