feat: ✨ add strict parameter to FastCRUD get
method
#54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR aims to add a parameter
strict
to FastCRUDget
method.Indeed, when one want to retrieve some instance with some filters, and there are many results, the get method returns the first it encounters but doesn't warn the user of the other ones in the database. It can be misleading when you expect only one row in your database but there are a lot of duplicates in the table and you get no error.
So, if once needs it, it can use the
strict
parameter in get method to get one or none element.strict
is by default on False to not disturb current behaviour 😄Changes
fast_crud.py: I added the strict parameter in the
get
methodTests
I added
test_get_strict_existing_record
intest_get.py
forsqlalchemy
andSQLModel
Checklist
Additional Notes