@@ -95,7 +95,6 @@ from typing import TYPE_CHECKING
9595from loguru import logger
9696
9797from {module}.core.security import get_password_hash, verify_password
98- from {module}.core.utils import create_db_primary_key
9998from {module}.exceptions import DbInsertError, DbUpdateError, UserNotFoundError
10099from {module}.models.users import (
101100 UpdatePassword,
@@ -127,16 +126,15 @@ async def authenticate(*, pool: Pool, email: str, password: str) -> UserInDb | N
127126async def create_user(*, pool: Pool, cache_client: Valkey, user: UserCreate) -> UserInDb:
128127 query = """
129128 INSERT INTO users (
130- id,
131129 email,
132130 full_name,
133131 hashed_password,
134132 is_active,
135133 is_superuser
136134 )
137- VALUES ($1, $2, $3, $4, $5, $6 )
135+ VALUES ($1, $2, $3, $4, $5)
138136 RETURNING
139- id,
137+ id::text ,
140138 email,
141139 full_name,
142140 hashed_password,
@@ -148,7 +146,6 @@ async def create_user(*, pool: Pool, cache_client: Valkey, user: UserCreate) ->
148146 async with pool.acquire() as conn:
149147 result = await conn.fetchrow(
150148 query,
151- create_db_primary_key(),
152149 user.email,
153150 user.full_name,
154151 get_password_hash(user.password),
@@ -167,7 +164,7 @@ async def create_user(*, pool: Pool, cache_client: Valkey, user: UserCreate) ->
167164
168165
169166async def delete_user(*, pool: Pool, cache_client: Valkey, user_id: str) -> None:
170- query = "DELETE FROM users WHERE id = $1"
167+ query = "DELETE FROM users WHERE id::text = $1"
171168 async with pool.acquire() as conn:
172169 async with asyncio.TaskGroup() as tg:
173170 db_task = tg.create_task(conn.execute(query, user_id))
@@ -183,7 +180,7 @@ async def delete_user(*, pool: Pool, cache_client: Valkey, user_id: str) -> None
183180
184181async def get_users(*, pool: Pool, offset: int = 0, limit: int = 100) -> list[UserInDb] | None:
185182 query = """
186- SELECT id,
183+ SELECT id::text ,
187184 email,
188185 full_name,
189186 hashed_password,
@@ -241,7 +238,7 @@ async def get_users_public(
241238
242239async def get_user_by_email(*, pool: Pool, email: str) -> UserInDb | None:
243240 query = """
244- SELECT id,
241+ SELECT id::text ,
245242 email,
246243 full_name,
247244 hashed_password,
@@ -278,15 +275,15 @@ async def get_user_by_id(*, pool: Pool, cache_client: Valkey, user_id: str) -> U
278275 return cached_user
279276
280277 query = """
281- SELECT id,
278+ SELECT id::text ,
282279 email,
283280 full_name,
284281 hashed_password,
285282 is_active,
286283 is_superuser,
287284 last_login
288285 FROM users
289- WHERE id = $1
286+ WHERE id::text = $1
290287 """
291288
292289 async with pool.acquire() as conn:
@@ -341,9 +338,9 @@ async def update_user(
341338 query = """
342339 UPDATE users
343340 SET hashed_password=$1
344- WHERE id = $2
341+ WHERE id::text = $2
345342 RETURNING
346- id,
343+ id::text ,
347344 email,
348345 full_name,
349346 hashed_password,
@@ -373,9 +370,9 @@ async def update_user(
373370 query = f"""
374371 UPDATE users
375372 SET {{set_clause}}
376- WHERE id = $1
373+ WHERE id::text = $1
377374 RETURNING
378- id,
375+ id::text ,
379376 email,
380377 full_name,
381378 hashed_password,
0 commit comments