Closed ghost closed 11 months ago
followers
table are primary keys, so they are always indexed.one_or_none()
method will raise an exception if two or more results are found matching the condition. The scalar()
would not.With the current schema it would never return more than one result.
User
inToken
is indexed, while the ones infollowers
table aren't?db.session.scalars(User.select().where(User.id == self.id, User.following.contains(user))).one_or_none() is not None
over something likedb.session.scalar(User.select().where(User.id == self.id, User.following.contains(user))) is not None
?Thanks!