#26283: SplitArrayField failed to validate because remove_trailing_nulls doesn't
work properly
----------------------------------+--------------------------------------
     Reporter:  mochawich         |                    Owner:
         Type:  Bug               |                   Status:  new
    Component:  contrib.postgres  |                  Version:  1.8
     Severity:  Normal            |               Resolution:
     Keywords:                    |             Triage Stage:  Unreviewed
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+--------------------------------------

Comment (by mochawich):

 I solved that by modifying the clean method of SplitArrayField


 {{{
         if self.remove_trailing_nulls:
             null_index = None
             for i, value in reversed(list(enumerate(cleaned_data))):
                 if value in self.base_field.empty_values:
                     null_index = i
                 else:
                     break
             if null_index is not None:
                 cleaned_data = cleaned_data[:null_index]
                 errors = errors[:null_index]

 }}}

 as the 0 index is still a valid index and shouldn't falsify the trimming
 condition.

--
Ticket URL: <https://code.djangoproject.com/ticket/26283#comment:3>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.540e16bff0d6818f1f53ec1c60875e2a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to