tortoise / tortoise/tortoise-orm
source_field break __iter__
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Describe the bug
When a field specifies source_field, Model.__iter__() no longer works.
To Reproduce
from tortoise import Model
from tortoise.fields import BigIntField
class SampleModel(Model):
id_ = BigIntField(pk=True, source_field='id')
a = SampleModel(id_=1)
[i for i in a]
Expected behavior
This iteration sho
Additional context
Python 3.10.4
tortoise-orm==0.19.0
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 by reproducing the example with a model field using source_field and inspect Model.iter together with the field-name handling. Confirm the expected iteration behavior from the issue context, then add coverage for the reproduction and verify that iteration works without breaking normal fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100