We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If we call an update crud without providing any change, an error will be thrown.
if not any(recommendation.model_dump().values()): return result = await db.execute( update(models_recommendation.Recommendation) .where(models_recommendation.Recommendation.id == recommendation_id) .values(**recommendation.model_dump(exclude_none=True)) ) if result.rowcount == 1: await db.commit() else: await db.rollback() raise ValueError
See @julien4215 comment
The text was updated successfully, but these errors were encountered:
Its seems the proposed solution does not work if some fields are set to False.
False
According to pydantic/pydantic#4613 we could use:
if not bool( recommendation.model_fields_set ):
If we need to exclude some fields from the model, we can use recommendation.model_fields_set - {"field_to_remove"},
recommendation.model_fields_set - {"field_to_remove"},
Sorry, something went wrong.
Use model_fields_set to check if at least a field is to be updated (#532
39aa9b3
) to prevent `False` values to be interpreted as not provided fields Related to #355
No branches or pull requests
Subject of the issue
If we call an update crud without providing any change, an error will be thrown.
Proposed solution
See @julien4215 comment
The text was updated successfully, but these errors were encountered: