tortoise / tortoise/tortoise-orm
Model.create method doesn't raise an error if it gets unexpected arg
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Hi, there! First of all, thanks for your amazing work!
The problem that cause feature request.
class SomeModel(models.Model):
id = fields.IntField(pk=True) # pylint: disable=invalid-name
obj = SomeModel.create(
nonexistent_field="lol"
)
The code above is executed without errors. It surprised me because I expect to see an error due to I specified the field that doesn't exist in the model.
Describe the solution you'd like
Maybe it will be good to add fields validation in the method and related methods as well?
I ready to contribute this feature if you consider it as useful. Thank for attention!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Model.create entry point and trace the related methods that accept model fields. Reproduce the issue with an unexpected argument, then determine the expected validation behavior across those methods. Done means invalid field names consistently raise an error without changing valid creation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100