fix(fastapi): adds proper check for null json for postgresql

This commit is contained in:
sauravniraula 2025-07-29 18:13:00 +05:45
parent 9cb7d9f432
commit 144bfcfe1a
No known key found for this signature in database
GPG key ID: 60FCC1B5A5E83326

View file

@ -5,7 +5,7 @@ import random
from typing import Annotated, List, Literal, Optional
from fastapi import APIRouter, Body, Depends, File, HTTPException, UploadFile
from fastapi.responses import StreamingResponse
from sqlalchemy import delete
from sqlalchemy import String, cast, delete, text
from sqlalchemy.ext.asyncio import AsyncSession
from sqlmodel import select
from constants.documents import UPLOAD_ACCEPTED_FILE_TYPES
@ -82,7 +82,9 @@ async def delete_presentation(
async def get_all_presentations(sql_session: AsyncSession = Depends(get_async_session)):
presentations_with_slides = []
presentations = await sql_session.scalars(
select(PresentationModel).where(PresentationModel.layout != "null")
select(PresentationModel).where(
cast(PresentationModel.layout, String) != "null"
)
)
async def inner(presentation: PresentationModel, sql_session: AsyncSession):