fix: correct dict cursor access in MediaWiki import
Error: 500 Internal Server Error on execute import Root cause: Using fetchone()[0] with RealDictCursor (dict-like rows) PostgreSQL RealDictCursor returns dict-like objects, not tuples. Accessing [0] on a dict throws TypeError. Fix: Changed all fetchone()[0] to fetchone()['id'] Locations: - Line 163: log_id after INSERT INTO wiki_import_log - Line 485: ex_id after INSERT INTO exercises - Line 599: skill_id after INSERT INTO skills - Line 616: method_id after INSERT INTO training_methods This matches the pattern used in other routers (exercises.py, etc.)
This commit is contained in:
parent
8b51864b53
commit
a37400bb22
|
|
@ -160,7 +160,7 @@ async def execute_import(
|
|||
RETURNING id""",
|
||||
(body.import_type, body.category, body.dry_run, body.reimport_existing, profile_id)
|
||||
)
|
||||
log_id = cur.fetchone()[0]
|
||||
log_id = cur.fetchone()['id']
|
||||
conn.commit()
|
||||
|
||||
# Import asynchron starten
|
||||
|
|
@ -482,7 +482,7 @@ def _upsert_exercise(mapped: dict, reimport: bool) -> Optional[int]:
|
|||
mapped.get("import_id"),
|
||||
)
|
||||
)
|
||||
ex_id = cur.fetchone()[0]
|
||||
ex_id = cur.fetchone()['id']
|
||||
|
||||
conn.commit()
|
||||
|
||||
|
|
@ -596,7 +596,7 @@ def _upsert_skill(mapped: dict, reimport: bool) -> Optional[int]:
|
|||
RETURNING id""",
|
||||
(mapped["name"], mapped.get("description"), category_id)
|
||||
)
|
||||
skill_id = cur.fetchone()[0]
|
||||
skill_id = cur.fetchone()['id']
|
||||
conn.commit()
|
||||
return skill_id
|
||||
|
||||
|
|
@ -613,7 +613,7 @@ def _upsert_method(mapped: dict, reimport: bool) -> Optional[int]:
|
|||
RETURNING id""",
|
||||
(mapped["name"], mapped.get("description"))
|
||||
)
|
||||
method_id = cur.fetchone()[0]
|
||||
method_id = cur.fetchone()['id']
|
||||
conn.commit()
|
||||
return method_id
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user