We were having a discussion on this matter on the Django under the Hood 
Slack channel, and there's a design decision that I think I can't take by 
myself.

There are 2 related subject : the "readonly" part and the "auto_refresh" 
part. Readonly means that the database won't try to write, autorefresh 
means that when creating /updating an instance, the value will be fetched 
from the database automatically

There was a debate on whether the readonly behaviour should imply 
auto_refresh, and there are cases that are good candidates for auto_refresh 
without readonly (autofields, serial fields etc.).

What I'd suggest, if we can get an agreement on this, would be to define 
those 2 behaviours completely independently (possibly as 2 different PRs, 
each with their tests and docs and such).

Auto_refresh could then be used for autofields with the quirk that some SQL 
DBs, will provide last_insert_rowid() (sqlite) or LAST_INSERT_ID() (mysql), 
while other use RETURNING (PGSQL / Oracle) allowing to use a single query.

Readonly, on its side, would only be a simple independent feature and its 
behaviour would do what the title says, no more, no less.

Do you think I need to do a DEP on this ?
If not, do you think it's ok if https://github.com/django/django/pull/7515 is 
changed to only do the readonly part, and we make another PR (and possibly 
ticket) for the "auto_refresh" part ?

While it would be nice to have both landing at the same time on master, I 
feel there's nothing blocking if they land at separate time, even in 
separate versions if need be (the freeze on Django 1.11 is coming fast, 
IIRC).

Are there usecases that I'm missing and that could not be expressed as a 
mix of readonly and auto_refresh ?

Le lundi 7 novembre 2016 15:35:38 UTC+1, Aymeric Augustin a écrit :
>
> On 7 Nov 2016, at 13:44, Joachim Jablon <ewjo...@gmail.com <javascript:>> 
> wrote: 
>
> > My own personal opinion: 1. refesh by default, add an argument to 
> "model_instance.save()" to opt-out. 2. readonly 
>
> I agree. 
>
> -- 
> Aymeric. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/3db52e5b-54db-4736-845b-58a22b6f015c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to