Opened 8 years ago

Last modified 8 years ago

#27222 new New feature

Refresh expressions on save — at Version 1

Reported by: holvianssi Owned by: nobody
Component: Database layer (models, ORM) Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by holvianssi)

The use case is automatically fetching the value for expressions when saving to DB. For example:

> user = User.objects.create(username=Lower('Anssi'))
> user.username == 'anssi'
True

While the above feature can be simulated somewhat easily by calling refresh_from_db() after save, an in-built implementation has the ability to use RETURNING as an optimization. In addition, it seems that refreshing objects on save would be a nice default, though this might be a bit backwards incompatible in some cases.

Change History (1)

comment:1 by holvianssi, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top