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

Add returning clause to update #111

Open feluelle opened 4 days ago

feluelle commented 4 days ago

Description

This change allows CRUD users to retrieve the updated record after performing an update operation by passing return_columns and optionally the model to load the response into.

Changes

closes: #106

We use the same args that we also use in other CRUD API functions to make it easier for users to understand and use them.

Tests

I have added tests for update operations returning a single row, multiple rows, with model and without (i.e. dict).

Checklist

feluelle commented 4 days ago

@JakNowy please take a look. Also, let me know where you think I should add docs about this, please.

JakNowy commented 3 days ago

This looks correct. However I share your opinion that ideally we would like to split that functionality into update and update_multi. I think in the upcoming major version we might even go further and have single update_multi which supports both single and multiple objects, without the "allow_multiple" constraint. If you wish, you're more than welcome to add that update_multi with simplified logic. Otherwise I'm going to approve that already.

feluelle commented 3 days ago

This looks correct. However I share your opinion that ideally we would like to split that functionality into update and update_multi. I think in the upcoming major version we might even go further and have single update_multi which supports both single and multiple objects, without the "allow_multiple" constraint. If you wish, you're more than welcome to add that update_multi with simplified logic. Otherwise I'm going to approve that already.

Let's make that a separate PR.

feluelle commented 2 days ago

@JakNowy where should I put docs about this?

JakNowy commented 2 days ago

I think this should be a good place.