Skip to content

Commit

Permalink
Prefer one_or_none() to first() for safety
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Jun 2, 2016
1 parent 31f3b07 commit 9b43af9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hasjob/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class EventSession(EventSessionBase, BaseMixin, db.Model):

@classmethod
def get_session(cls, uuid, user=None, anon_user=None):
ues = cls.query.filter_by(uuid=uuid).first() if uuid else None
ues = cls.query.filter_by(uuid=uuid).one_or_none() if uuid else None

# We no longer hard-link sessions to users, so this is commented out:
# if (not not user) + (not not anon_user) != 1:
Expand Down

0 comments on commit 9b43af9

Please sign in to comment.