igorbenav / fastcrud

FastCRUD is a Python package for FastAPI, offering robust async CRUD operations and flexible endpoint creation utilities.
MIT License
530 stars 32 forks source link

Soft deleted entries are returned by default #63

Open waza-ari opened 2 months ago

waza-ari commented 2 months ago

Describe the bug or question As far as I can tell, the soft delete columns are not taken into account when returning entries from the database using any of the get methods.

Description When using the soft delete columns, they are set correctly when using the FastCRUD.delete() method. When retrieving objects however, it is not taken into account whether the object was soft deleted or not. Maybe this is an intentional design choice and wrong expectations on my side, but I was assuming that by default soft deleted objects would not be returned, potentially with an option to return them by using a parameter.

igorbenav commented 2 months ago

It was an intentional design choice, I'm not sure if it's the most intuitive. If by default it excluded is_deleted=True, I think it would add complexity for the other cases (if you want to retrieve all of them and specially if you want to retrieve only deleted records).

For the second case we could end up with something like:

crud.get(db=db, return_deleted=True, is_deleted=True)

And we'd still need to deal with a case like:

crud.get(db=db, return_deleted=True, is_deleted=False)

In any case, I'd like to hear more opinions on this.