#24328: The new Options._get_fields() method needs to be cleaned up
-------------------------------------+-------------------------------------
               Reporter:  akaariai   |          Owner:  nobody
                   Type:             |         Status:  new
  Cleanup/optimization               |
              Component:  Database   |        Version:  1.8alpha1
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 At least the method _get_fields() has a lot of places where the code isn't
 as clean as it should be.

 Examples from master:
   - The method has a flag export_ordered_set, but that flag is never used,
 and the method definitely doesn't export an ordered set.
   - The comment in the first try-catch states that the method must always
 return a shallow copy. However, the comment doesn't make any sense in that
 location (the code doesn't make a shallow copy in that location)
   - The method constructs an OrderedDict of field -> boolean. The boolean
 flag is always True and never used. It would be possible to use an
 ordinary list instead.
   - The comment in the beginning of "if not export_ordered_set" isn't
 accurate, it states that
    {{{
     # By default, fields contains field instances as keys and all
                # possible names if the field instance as values. When
                # _get_fields() is called, we only want to return field
 instances,
                # so we just preserve the keys.
    }}}
    this comment doesn't make much sense.

 Other parts of the code seem to be lot better. In addition, L592 contains
 f.rel.field.rel.is_hidden(). But f.rel.field.rel is always the same as
 f.rel. L476 states that the code calls _get_fields() with
 export_ordered_set=True, but that isn't actually happening.

 The functionality itself seems to be fine, but there is just a lot of
 left-overs from internal refactorings.

--
Ticket URL: <https://code.djangoproject.com/ticket/24328>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.6c70b57731bab0302f176616e20c56c1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to