CodeBench: qwen3:8b primary-rooliin, FK-esimerkit code-small promptissa

profiles.json: role-kenttä (primary/backup/minimal/retired).
code-small.md: lisätty konkreettinen FK-pattern ja testi-esimerkki
relaatioille — 8b:n blog-skenaario kaatui koska ei osannut FK:ta.
This commit is contained in:
2026-04-14 13:55:40 +03:00
parent 92964e322f
commit 7fe72480b1
2 changed files with 45 additions and 7 deletions

View File

@@ -15,6 +15,34 @@ Key patterns (copy from reference):
- model_dump() not dict()
- POST 201, GET list, GET by id 404, PUT, DELETE 204
FOREIGN KEYS (when spec has relationships):
- Child entity gets parent_id field: Mapped[int] = mapped_column(ForeignKey("parents.id"))
- Import ForeignKey: from sqlalchemy import ForeignKey
- Create schema includes parent_id: int
- Test creates parent FIRST, then child with parent's id
Example FK pattern in models.py:
```
class Author(Base):
__tablename__ = "authors"
id: Mapped[int] = mapped_column(primary_key=True, index=True)
name: Mapped[str] = mapped_column(String(255))
class Post(Base):
__tablename__ = "posts"
id: Mapped[int] = mapped_column(primary_key=True, index=True)
title: Mapped[str] = mapped_column(String(255))
author_id: Mapped[int] = mapped_column(ForeignKey("authors.id"))
```
Example FK test pattern:
```
def test_create_post():
author = client.post("/authors/", json={"name": "Kirjailija"}).json()
response = client.post("/posts/", json={"title": "Artikkeli", "author_id": author["id"]})
assert response.status_code == 201
```
CRITICAL:
- Use ONLY fields from the JSON spec — no created_at or extra fields
- Generate EXACTLY 6 tests per entity: create, list, get_by_id, not_found, update, delete