fix: Remove broken table_exists check
Removed faulty EXISTS check that was causing "0" error. Added debug logging and better error messages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
484c25575d
commit
8be87bfdfb
2 files changed
+10
-22
No files matched your search
@@ -504,26 +504,10 @@ def list_goal_type_definitions(session: dict = Depends(require_auth)):
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
|
||||
# Check if table exists first
|
||||
cur.execute("""
|
||||
SELECT EXISTS (
|
||||
SELECT FROM information_schema.tables
|
||||
WHERE table_name = 'goal_type_definitions'
|
||||
)
|
||||
""")
|
||||
table_exists = cur.fetchone()[0]
|
||||
|
||||
if not table_exists:
|
||||
print("[ERROR] goal_type_definitions table does not exist!")
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail="Goal Types Tabelle existiert nicht. Migration 024 muss ausgeführt werden."
|
||||
)
|
||||
|
||||
cur.execute("""
|
||||
SELECT id, type_key, label_de, label_en, unit, icon, category,
|
||||
source_table, source_column, aggregation_method,
|
||||
calculation_formula, description, is_system,
|
||||
calculation_formula, description, is_system, is_active,
|
||||
created_at, updated_at
|
||||
FROM goal_type_definitions
|
||||
WHERE is_active = true
|
||||
@@ -535,9 +519,10 @@ def list_goal_type_definitions(session: dict = Depends(require_auth)):
|
||||
label_de
|
||||
""")
|
||||
|
||||
return [r2d(row) for row in cur.fetchall()]
|
||||
except HTTPException:
|
||||
raise
|
||||
results = [r2d(row) for row in cur.fetchall()]
|
||||
print(f"[DEBUG] Loaded {len(results)} goal types")
|
||||
return results
|
||||
|
||||
except Exception as e:
|
||||
print(f"[ERROR] list_goal_type_definitions failed: {e}")
|
||||
print(traceback.format_exc())
|
||||
|
||||
Reference in new issue
Block a user