MongoEngine / MongoEngine/mongoengine
Reload is not working when the field name is "items"
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
Here is the data model where reload works
class TestDoc(Document):
item = IntField()
t_d = TestDoc()
t_d.item = 1
t_d.save()
TestDoc.objects(id=t_d.id).update(inc__item = 10)
t_d.to_json()
t_d.reload()
t_d.to_json()
Results in
'{"_id": {"$oid": "57985aa6aafbb30e5e2e076b"}, "item": 1}'
'{"_id": {"$oid": "57985aa6aafbb30e5e2e076b"}, "item": 11}'
which is the correct result.
Now change the model to
class TestDoc1(Document):
items = IntField()
t_d = TestDoc1()
t_d.items = 1
t_d.save()
TestDoc1.objects(id=t_d.id).update(inc__items = 10)
t_d.to_json()
t_d.reload()
t_d.to_json()
Results in
'{"_id": {"$oid": "57985be1aafbb30e5e2e076c"}, "items": 1}'
'{"_id": {"$oid": "57985be1aafbb30e5e2e076c"}, "items": 1}'
which is not the incorrect one.
Is there something which I am doing wrong or this is by design.
TIA :)
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
Reproduce the issue with the two TestDoc and TestDoc1 snippets, focusing on the difference between the item and items fields. Trace the Document.reload entry point and verify that the items value changes from 1 to 11 after the database increment, without changing the working item case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100