Skip to content

Commit

Permalink
Use filter instead of filter_by in SQL queries with joins
Browse files Browse the repository at this point in the history
Avoids errors with SQLAlchemy v1.4.
  • Loading branch information
homeworkprod committed Feb 20, 2021
1 parent bd414bf commit f09d077
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion byceps/services/authorization/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def get_permission_ids_for_user(user_id: UserID) -> Set[PermissionID]:
role_permissions = DbRolePermission.query \
.join(DbRole) \
.join(DbUserRole) \
.filter_by(user_id=user_id) \
.filter(DbUserRole.user_id == user_id) \
.all()

return {rp.permission_id for rp in role_permissions}
Expand Down
2 changes: 1 addition & 1 deletion byceps/services/board/aggregation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def aggregate_category(category: DbCategory) -> None:
posting_query = DbPosting.query \
.without_hidden() \
.join(DbTopic) \
.filter_by(category=category)
.filter(DbTopic.category_id == category.id)

posting_count = posting_query.count()

Expand Down
2 changes: 1 addition & 1 deletion byceps/services/orga_team/dbmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __repr__(self) -> str:
class MembershipQuery(BaseQuery):

def for_party(self, party_id: PartyID) -> BaseQuery:
return self.join(OrgaTeam).filter_by(party_id=party_id)
return self.join(OrgaTeam).filter(OrgaTeam.party_id == party_id)


class Membership(db.Model):
Expand Down

0 comments on commit f09d077

Please sign in to comment.