This commit is contained in:
parent
fdedb75a2c
commit
1c61e889d6
|
@ -1,3 +1,10 @@
|
||||||
|
#### [0.4.18] - 2025-04-10
|
||||||
|
- Fixed unique constraint violation for empty slug values:
|
||||||
|
- Modified `update_draft` resolver to handle empty slug values
|
||||||
|
- Modified `create_draft` resolver to prevent empty slug values
|
||||||
|
- Added validation to prevent inserting or updating drafts with empty slug
|
||||||
|
- Fixed database error "duplicate key value violates unique constraint draft_slug_key"
|
||||||
|
|
||||||
#### [0.4.17] - 2025-03-26
|
#### [0.4.17] - 2025-03-26
|
||||||
- Fixed `'Reaction' object is not subscriptable` error in hierarchical comments:
|
- Fixed `'Reaction' object is not subscriptable` error in hierarchical comments:
|
||||||
- Modified `get_reactions_with_stat()` to convert Reaction objects to dictionaries
|
- Modified `get_reactions_with_stat()` to convert Reaction objects to dictionaries
|
||||||
|
|
|
@ -105,6 +105,11 @@ async def create_draft(_, info, draft_input):
|
||||||
if "title" not in draft_input or not draft_input["title"]:
|
if "title" not in draft_input or not draft_input["title"]:
|
||||||
draft_input["title"] = "" # Пустая строка вместо NULL
|
draft_input["title"] = "" # Пустая строка вместо NULL
|
||||||
|
|
||||||
|
# Проверяем slug - он должен быть или не пустым, или не передаваться вообще
|
||||||
|
if "slug" in draft_input and (draft_input["slug"] is None or draft_input["slug"] == ""):
|
||||||
|
# При создании черновика удаляем пустой slug из входных данных
|
||||||
|
del draft_input["slug"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
# Remove id from input if present since it's auto-generated
|
# Remove id from input if present since it's auto-generated
|
||||||
|
@ -142,6 +147,15 @@ async def update_draft(_, info, draft_id: int, draft_input):
|
||||||
if not user_id or not author_id:
|
if not user_id or not author_id:
|
||||||
return {"error": "Author ID are required"}
|
return {"error": "Author ID are required"}
|
||||||
|
|
||||||
|
# Проверяем slug - он должен быть или не пустым, или не передаваться вообще
|
||||||
|
if "slug" in draft_input and (draft_input["slug"] is None or draft_input["slug"] == ""):
|
||||||
|
# Если slug пустой, либо удаляем его из входных данных, либо генерируем временный уникальный
|
||||||
|
# Вариант 1: просто удаляем ключ из входных данных, чтобы оставить старое значение
|
||||||
|
del draft_input["slug"]
|
||||||
|
# Вариант 2 (если нужно обновить): генерируем временный уникальный slug
|
||||||
|
# import uuid
|
||||||
|
# draft_input["slug"] = f"draft-{uuid.uuid4().hex[:8]}"
|
||||||
|
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
draft = session.query(Draft).filter(Draft.id == draft_id).first()
|
draft = session.query(Draft).filter(Draft.id == draft_id).first()
|
||||||
if not draft:
|
if not draft:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user