#10244: FileFields can't be set to NULL in the db
-------------------------------------+-------------------------------------
     Reporter:  oyvind               |                    Owner:  Ondrej
                                     |  Pudiš
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  1.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  filefield NULL       |             Triage Stage:  Accepted
  empty                              |
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Ondrej Pudiš):

 * has_patch:  0 => 1


Comment:

 
[https://code.djangoproject.com/attachment/ticket/10244/nullable_file_field.diff
 My proposed patch] is to not create an instance of `FieldFile` when the
 file is `None`. However, this is a significant breaking change as people
 might be accessing the `FileField` and checking for `name` or `path` being
 an empty string.

 Many tests would need to be adjusted to this new logic.

 As suggested earlier, another possibility would be to store `None` on the
 DB level while interpreting it as  an empty `FieldFile` on the application
 level. This cloud introduce more confusion to the whole mechanics of the
 files storing.

 I believe that the first approach with not creating the `FieldFile` object
 when the file doesn't actually exists is a cleaner solution which is
 consistent with other types of database fields.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/10244#comment:21>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701837001c710-94745d3e-29de-4260-a714-7af04cca3fd1-000000%40eu-central-1.amazonses.com.

Reply via email to