vsdudakov / fastadmin

FastAdmin is an easy-to-use Admin Dashboard App for FastAPI/Flask/Django inspired by Django Admin.
https://vsdudakov.github.io/fastadmin/
MIT License
116 stars 14 forks source link

orm_delete_obj should commit delete #51

Closed samy38 closed 1 month ago

samy38 commented 1 month ago

Hello,

i'm using fastapi + sqlalchemy with a sqlite db. When i'm deleting records they are not deleted.

When i check sqlalchemy.py code i have the following:

    async def orm_delete_obj(self, id: UUID | int) -> None:
        """This method is used to delete orm/db model object.

        :params id: an id of object.
        :return: None.
        """
        sessionmaker = self.get_sessionmaker()
        async with sessionmaker() as session:
            obj = await session.get(self.model_cls, id)
            await session.delete(obj)

i think you shoud add await session.commit() like in orm_save_obj method

vsdudakov commented 1 month ago

Good catch @samy38 ! Thank you! I will fix it.

vsdudakov commented 1 month ago

@samy38 this issue has to be fixed in 0.2.8