[Django] #29979: Refactor AutoField logic into a mixin, implement checks and validators.

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #29979: Refactor AutoField logic into a mixin, implement checks and validators.

Django
#29979: Refactor AutoField logic into a mixin, implement checks and validators.
-------------------------------------+-------------------------------------
               Reporter:  Nick Pope  |          Owner:  Nick Pope
                   Type:             |         Status:  assigned
  Cleanup/optimization               |
              Component:  Database   |        Version:  master
  layer (models, ORM)                |       Keywords:  autofield,
               Severity:  Normal     |  validators
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Currently `AutoField` inherits from `Field` and `BigAutoField` from
 `AutoField`. In effect they largely redefine `IntegerField` and
 `BigIntegerField` respectively, but add in the auto field "behaviour". As
 a result they do not perform some of the system checks, e.g. `max_length`
 warning, nor the validation checks, e.g. range checks, that the integer
 fields do.

 The proposal is to move all the auto field "behaviour" into a new
 `AutoFieldMixin` and fix `AutoField` and `BigAutoField` to inherit from
 this new mixin and `IntegerField` and `BigIntegerField` respectively.

 Many attributes and methods would be nicely inherited from the correct
 parent field type without requiring redefinition:

 - `description`
 - `empty_strings_allowed`
 - `default_error_messages`
 - `get_prep_value()`
 - `to_python()`

 `AutoField` and `BigAutoField` could also inherit the following checks
 from `IntegerField`:

 - `IntegerField._check_max_length_warning()`

 `AutoField` and `BigAutoField` could also perform minimum and maximum
 value validation checks inherited from `IntegerField`.

 This should be backwards compatible and potentially will make it easier to
 define new types of auto fields based on other fields in the future.

--
Ticket URL: <https://code.djangoproject.com/ticket/29979>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/050.1339ca16616f68e2dc089c6edc3e9b69%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29979: Refactor AutoField logic into a mixin, implement checks and validators.

Django
#29979: Refactor AutoField logic into a mixin, implement checks and validators.
-------------------------------------+-------------------------------------
     Reporter:  Nick Pope            |                    Owner:  Nick Pope
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  autofield,           |             Triage Stage:
  validators                         |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Nick Pope):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/10680 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29979#comment:1>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.a2e4873b266b92d9ee08b75c49ca27bc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29979: Refactor AutoField logic into a mixin, implement checks and validators.

Django
In reply to this post by Django
#29979: Refactor AutoField logic into a mixin, implement checks and validators.
-------------------------------------+-------------------------------------
     Reporter:  Nick Pope            |                    Owner:  Nick Pope
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  autofield,           |             Triage Stage:  Accepted
  validators                         |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * stage:  Unreviewed => Accepted


Comment:

 Conversation on the PR is already on-going. I’ll provisionally accept this
 pending an implementation everyone is happy with.
 (Seems reasonable in principle.)

--
Ticket URL: <https://code.djangoproject.com/ticket/29979#comment:2>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.6103c1574d642dbb38a709a6b9464243%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29979: Refactor AutoField logic into a mixin, implement checks and validators.

Django
In reply to this post by Django
#29979: Refactor AutoField logic into a mixin, implement checks and validators.
-------------------------------------+-------------------------------------
     Reporter:  Nick Pope            |                    Owner:  Nick Pope
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  autofield,           |             Triage Stage:  Accepted
  validators                         |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * needs_better_patch:  0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29979#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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.e9bf786e77a29b401eccf1970f60a8b5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29979: Refactor AutoField logic into a mixin, implement checks and validators.

Django
In reply to this post by Django
#29979: Refactor AutoField logic into a mixin, implement checks and validators.
-------------------------------------+-------------------------------------
     Reporter:  Nick Pope            |                    Owner:  Nick Pope
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  autofield,           |             Triage Stage:  Accepted
  validators                         |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Nick Pope):

 * needs_better_patch:  1 => 0


Comment:

 [https://github.com/django/django/pull/10680 PR] updated. It seems that
 this also partially addresses #17337, but that will further depend on #470
 for default values for non-integer fields as well as #24042 for replacing
 `isinstance(..., AutoField)` checks.

--
Ticket URL: <https://code.djangoproject.com/ticket/29979#comment:4>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.516e056e0bd97c32d141d731ddcf656e%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29979: Refactor AutoField logic into a mixin, implement checks and validators.

Django
In reply to this post by Django
#29979: Refactor AutoField logic into a mixin, implement checks and validators.
-------------------------------------+-------------------------------------
     Reporter:  Nick Pope            |                    Owner:  Nick Pope
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  autofield,           |             Triage Stage:  Accepted
  validators                         |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"21e559495b8255bba1e8a4429cd083246ab90457" 21e5594]:
 {{{
 #!CommitTicketReference repository=""
 revision="21e559495b8255bba1e8a4429cd083246ab90457"
 Fixed #29979, Refs #17337 -- Extracted AutoField field logic into a mixin
 and refactored AutoFields.

 This reduces duplication by allowing AutoField, BigAutoField and
 SmallAutoField to inherit from IntegerField, BigIntegerField and
 SmallIntegerField respectively. Doing so also allows for enabling the
 max_length warning check and minimum/maximum value validation for auto
 fields, as well as providing a mixin that can be used for other possible
 future auto field types such as a theoretical UUIDAutoField.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29979#comment:5>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.9a4c3a77fef47fbf62d92567fede275c%40djangoproject.com.