On Wed, Oct 16, 2013 at 12:15 AM, Cal Leeming [Simplicity Media Ltd] <
[email protected]> wrote:

> Sorry I should have made myself a little more clear.
>
> When I said "invalidating data inside your models" I was referring to any
> previous data that was saved when the validator was set to a minimum length
> of 4 characters. By then changing the validator to be 5 characters, you are
> effectively breaking save() on any data that was saved before that point,
> and the ability to fix the model data may not be available in that specific
> save() context. For example, a cron job that updates a "last_checked" field
> on the user would not necessarily have data relevant to changes in the
> users phone number (which could have its min/max length changed at any
> point in the validators life time).
>
> Hope that makes more sense
>
> Your analysis is correct, but you're possibly over thinking this a bit.

Consider a world in which model validation *was* on by default. You write
some models with a char field, and you insert some data. All valid, all
saved successfully. Now you change your models and add a validation
condition. You've just exposed yourself to exactly the same situation,
without feature-level backwards compatibility ever being part of the
picture.

What this highlights is that migration needs to be part of the whole
solution. At the very least, as part of adding default model validation,
we'd need to document the fact that all existing data must be assumed to be
potentially invalid, and provide an easy way to force validation.
Unfortunately, there's not sure I see any easy way to do this other than a
"for model in database: model.save()" loop.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAJxq848-%3DwSerY4HT9zAcff9YVtjQLm7Xf6EmA_JhF3MX7xFkA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to