tortoise / tortoise-orm

Familiar asyncio ORM for python, built with relations in mind
https://tortoise.github.io
Apache License 2.0
4.39k stars 357 forks source link

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

Open itzNikshit opened 7 months ago

itzNikshit commented 7 months ago

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.

Prof1-web commented 7 months ago

auto_now it's default value for the field. You shouldn't pass this field to update_fields, if you want automatic updating

itzNikshit commented 7 months ago

auto_now it's default value for the field. You shouldn't pass this field to update_fields, if you want automatic updating

But if I don't pass it in update_fields, the updated_at doesn't update on .save()