Coverage for src/kwai/modules/identity/users/user_account_db_query.py: 100%
18 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.modules.identity.users.user_account import UserAccountIdentifier
8from kwai.modules.identity.users.user_account_query import UserAccountQuery
9from kwai.modules.identity.users.user_tables import UserAccountRow
12class UserAccountDbQuery(UserAccountQuery, DatabaseQuery):
13 """A user account query for a database."""
15 def init(self):
16 self._query.from_(UserAccountRow.__table_name__)
18 @property
19 def columns(self):
20 return UserAccountRow.get_aliases()
22 def filter_by_id(self, id_: UserAccountIdentifier) -> Self:
23 self._query.and_where(UserAccountRow.field("id").eq(id_.value))
24 return self
26 def filter_by_email(self, email: EmailAddress) -> Self:
27 self._query.and_where(UserAccountRow.field("email").eq(str(email)))
28 return self