Skip to content
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

Merged
merged 3 commits into from
Dec 22, 2022

Conversation

dpgaspar
Copy link
Owner

@dpgaspar dpgaspar commented Dec 22, 2022

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

  • Has associated issue:
  • Is CRUD MVC related.
  • Is Auth, RBAC security related.
  • Changes the security db schema.
  • Introduces new feature
  • Removes existing feature

@codecov
Copy link

codecov bot commented Dec 22, 2022

Codecov Report

Merging #1971 (2813163) into master (bccba72) will increase coverage by 0.00%.
The diff coverage is 80.48%.

@@           Coverage Diff           @@
##           master    #1971   +/-   ##
=======================================
  Coverage   78.12%   78.13%           
=======================================
  Files          71       71           
  Lines        8609     8612    +3     
=======================================
+ Hits         6726     6729    +3     
  Misses       1883     1883           
Flag Coverage Δ
python 78.13% <80.48%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
flask_appbuilder/base.py 84.58% <ø> (ø)
flask_appbuilder/baseviews.py 89.64% <ø> (ø)
flask_appbuilder/models/sqla/interface.py 81.92% <78.37%> (+0.03%) ⬆️
flask_appbuilder/api/__init__.py 96.31% <100.00%> (+0.01%) ⬆️

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):
Copy link
Owner Author

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:
Copy link
Owner Author

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 [
Copy link
Owner Author

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

Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant