Spaces:
Running
Running
axeronis commited on
Commit ·
9336d62
1
Parent(s): 534384c
fix: add flag_modified for ai_settings JSON to ensure SQLAlchemy tracks changes
Browse files
backend/app/api/tenants.py
CHANGED
|
@@ -2,6 +2,7 @@ from fastapi import APIRouter, Depends, HTTPException, status
|
|
| 2 |
from sqlmodel import select, SQLModel
|
| 3 |
from datetime import datetime
|
| 4 |
from sqlmodel.ext.asyncio.session import AsyncSession
|
|
|
|
| 5 |
from typing import Optional, Dict, Any, List
|
| 6 |
from uuid import UUID
|
| 7 |
from pydantic import BaseModel
|
|
@@ -244,6 +245,9 @@ async def update_my_tenant(
|
|
| 244 |
if request.voice_reference_url is not None:
|
| 245 |
tenant.voice_reference_url = request.voice_reference_url
|
| 246 |
|
|
|
|
|
|
|
|
|
|
| 247 |
session.add(tenant)
|
| 248 |
await session.commit()
|
| 249 |
await session.refresh(tenant)
|
|
@@ -444,7 +448,9 @@ async def update_tenant(
|
|
| 444 |
if request.booking_settings is not None:
|
| 445 |
tenant.booking_settings = request.booking_settings
|
| 446 |
|
| 447 |
-
# 5. CRITICAL:
|
|
|
|
|
|
|
| 448 |
session.add(tenant)
|
| 449 |
await session.commit()
|
| 450 |
await session.refresh(tenant)
|
|
|
|
| 2 |
from sqlmodel import select, SQLModel
|
| 3 |
from datetime import datetime
|
| 4 |
from sqlmodel.ext.asyncio.session import AsyncSession
|
| 5 |
+
from sqlalchemy.orm.attributes import flag_modified
|
| 6 |
from typing import Optional, Dict, Any, List
|
| 7 |
from uuid import UUID
|
| 8 |
from pydantic import BaseModel
|
|
|
|
| 245 |
if request.voice_reference_url is not None:
|
| 246 |
tenant.voice_reference_url = request.voice_reference_url
|
| 247 |
|
| 248 |
+
# Mark ai_settings as modified so SQLAlchemy tracks JSON changes
|
| 249 |
+
flag_modified(tenant, "ai_settings")
|
| 250 |
+
|
| 251 |
session.add(tenant)
|
| 252 |
await session.commit()
|
| 253 |
await session.refresh(tenant)
|
|
|
|
| 448 |
if request.booking_settings is not None:
|
| 449 |
tenant.booking_settings = request.booking_settings
|
| 450 |
|
| 451 |
+
# 5. CRITICAL: Mark ai_settings as modified for SQLAlchemy JSON tracking
|
| 452 |
+
flag_modified(tenant, "ai_settings")
|
| 453 |
+
|
| 454 |
session.add(tenant)
|
| 455 |
await session.commit()
|
| 456 |
await session.refresh(tenant)
|