From f4db47d35d6eda1679f87da983dc031eefc8cc81 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 22 Jun 2020 18:45:52 +0200 Subject: [PATCH] publish: 5.9.1 --- pyproject.toml | 2 +- royalnet/backpack/tables/users.py | 11 ++++++++--- royalnet/version.py | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5c05d946..2623ae08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "royalnet" - version = "5.9.0" + version = "5.9.1" description = "A multipurpose bot and web framework" authors = ["Stefano Pigozzi "] license = "AGPL-3.0+" diff --git a/royalnet/backpack/tables/users.py b/royalnet/backpack/tables/users.py index c4e042be..c9887ef3 100644 --- a/royalnet/backpack/tables/users.py +++ b/royalnet/backpack/tables/users.py @@ -36,9 +36,14 @@ class User: def avatar_url(self): return Column(String) - @staticmethod - async def find(alchemy, session, alias: Union[str, int]): - result = await ru.asyncify(session.query(alchemy.get(Alias)).filter_by(alias=alias.lower()).one_or_none) + @classmethod + async def find(cls, alchemy, session, alias: Union[str, int]): + if isinstance(alias, str): + result = await ru.asyncify(session.query(alchemy.get(Alias)).filter_by(alias=alias.lower()).one_or_none) + elif isinstance(alias, int): + result = await ru.asyncify(session.query(alchemy.get(cls)).get, alias) + else: + raise TypeError("alias is of an invalid type.") if result is not None: result = result.user return result diff --git a/royalnet/version.py b/royalnet/version.py index 83d32d3e..6c855539 100644 --- a/royalnet/version.py +++ b/royalnet/version.py @@ -1 +1 @@ -semantic = "5.9.0" +semantic = "5.9.1"