Skip to content

Commit

Permalink
fix: improve performance for get role permissions (#1624)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgaspar authored Apr 26, 2021
1 parent 159de35 commit 5a76618
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions flask_appbuilder/security/sqla/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from sqlalchemy import and_, func, literal
from sqlalchemy.engine.reflection import Inspector
from sqlalchemy.orm import contains_eager
from sqlalchemy.orm.exc import MultipleResultsFound
from werkzeug.security import generate_password_hash

Expand Down Expand Up @@ -369,6 +370,8 @@ def get_db_role_permissions(self, role_id: int) -> List[PermissionView]:
.join(ViewMenu)
.join(PermissionView.role)
.filter(Role.id == role_id)
.options(contains_eager(PermissionView.permission))
.options(contains_eager(PermissionView.view_menu))
.all()
)

Expand Down

0 comments on commit 5a76618

Please sign in to comment.