Fix incorrectly case sensitive username finding in db. Fixes #384

This commit is contained in:
Tulir Asokan
2019-11-30 15:21:47 +02:00
parent 25d7087d07
commit 91e6a73f33
6 changed files with 15 additions and 9 deletions
+2 -2
View File
@@ -15,7 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from typing import Optional, Iterable, Tuple
from sqlalchemy import Column, ForeignKey, ForeignKeyConstraint, Integer, String
from sqlalchemy import Column, ForeignKey, ForeignKeyConstraint, Integer, String, func
from mautrix.types import UserID
from mautrix.util.db import Base
@@ -46,7 +46,7 @@ class User(Base):
@classmethod
def get_by_username(cls, username: str) -> Optional['User']:
return cls._select_one_or_none(cls.c.tg_username == username)
return cls._select_one_or_none(func.lower(cls.c.tg_username) == username)
@property
def contacts(self) -> Iterable[TelegramID]: