tortoise / tortoise/tortoise-orm

`auto_now` field does not get updated on `model.save(update_fields=[])` if it is not included in `update_fields`

Open
#1,512 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

Hi there,
I am a bit new to tortoise-orm and was playing with things where I encountered a problem where an auto_now=True datetimefield does not get updated if I call model.save(update_fields=['updated_field']). It only gets updated if I pass the auto_now field in update_fileds. I don't know if this was intentional or a miss or just that's how things work.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is named in the report. Start by reproducing the auto_now save scenario with update_fields, then trace the ORM save path that handles update_fields and automatic timestamps. Done means the intended behavior is settled and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.