feat(nadia): Fix BadgeOut schema to map badge_name database column
No verification applicable: the full test suite (`make test`) requires Python >=3.12 and the `dataset` package, but this environment has Python 3.11.2 and cannot install dependencies due to the version requirement mismatch in `pyproject.toml`. This is a pre-existing environment limitation, not caused by the change. The change itself has been verified via:
- `python3 -m py_compile devplacepy/schemas/content.py` → exit 0 (syntax valid)
- Standalone Pydantic test confirming `BadgeOut.model_validate({'badge_name': 'First Post', ...}).name == 'First Post'`
- Minimal 3-hunk diff touching only `content.py`
```text
Outcome: done
Changed: devplacepy/schemas/content.py:7-8, 66, 68
Verified by: py_compile → exit 0; standalone Pydantic schema behavior test (6 assertions, all passed)
Findings:
- BadgeOut.name at devplacepy/schemas/content.py:66 now has Field(alias='badge_name') mapping DB column badge_name → name field
- BadgeOut.model_config at devplacepy/schemas/content.py:68 has populate_by_name=True so badges accept both badge_name (DB input) and name (existing JSON consumers)
- model_dump(mode='json') produces {'name': ..., ...} by default — no breakage for existing API consumers
- HTML template path (profile.html) reads badge['badge_name'] from raw DB dict, completely unaffected by this change
Open: none
Confidence: high - schema behavior verified with direct Pydantic tests, py_compile passes, 3-line diff is minimal and correct
```
Typosaurus-Run: cf8155d8183146ecbb92790b22f8c980
Typosaurus-Node: d9667bfd04d34c35a0872e40299fc1f8
Typosaurus-Agent: @nadia
Refs: #113
This commit is contained in:
parent
e05f97c924
commit
46f87a48e3
@ -4,6 +4,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
from pydantic import ConfigDict, Field
|
||||||
|
|
||||||
from devplacepy.schemas.base import _Out
|
from devplacepy.schemas.base import _Out
|
||||||
|
|
||||||
|
|
||||||
@ -62,8 +64,9 @@ class PollOut(_Out):
|
|||||||
|
|
||||||
|
|
||||||
class BadgeOut(_Out):
|
class BadgeOut(_Out):
|
||||||
name: Optional[str] = None
|
name: Optional[str] = Field(None, alias="badge_name")
|
||||||
created_at: Optional[str] = None
|
created_at: Optional[str] = None
|
||||||
|
model_config = ConfigDict(populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
class PostOut(_Out):
|
class PostOut(_Out):
|
||||||
@ -202,3 +205,4 @@ class MessageOut(_Out):
|
|||||||
|
|
||||||
|
|
||||||
CommentItemOut.model_rebuild()
|
CommentItemOut.model_rebuild()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user