Coverage for src/kwai/modules/identity/users/user_account_db_query.py: 100%
22 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module that implements the UserAccountQuery interface for a database."""
3from typing import Self
5from kwai.core.db.database_query import DatabaseQuery
6from kwai.core.domain.value_objects.email_address import EmailAddress
7from kwai.core.domain.value_objects.unique_id import UniqueId
8from kwai.modules.identity.users.user_account import UserAccountIdentifier
9from kwai.modules.identity.users.user_account_query import UserAccountQuery
10from kwai.modules.identity.users.user_tables import UserAccountRow
13class UserAccountDbQuery(UserAccountQuery, DatabaseQuery):
14 """A user account query for a database."""
16 def init(self):
17 self._query.from_(UserAccountRow.__table_name__)
19 @property
20 def columns(self):
21 return UserAccountRow.get_aliases()
23 def filter_by_id(self, id_: UserAccountIdentifier) -> Self:
24 self._query.and_where(UserAccountRow.field("id").eq(id_.value))
25 return self
27 def filter_by_email(self, email: EmailAddress) -> Self:
28 self._query.and_where(UserAccountRow.field("email").eq(str(email)))
29 return self
31 def filter_by_uuid(self, uuid: UniqueId) -> Self:
32 self._query.and_where(UserAccountRow.field("uuid").eq(str(uuid)))
33 return self