#27446: Addition of `readonly` option to ModelField to allow database generated
fields
-------------------------------------+-------------------------------------
     Reporter:  Ben Cole             |                    Owner:  Ben Cole
         Type:  New feature          |                   Status:  assigned
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     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
-------------------------------------+-------------------------------------
Description changed by Ben Cole:

Old description:

> There exist multiple use cases where a database will generate values for
> a field/column. Most RDBMSes expect that these columns be excluded from
> from `INSERT` and `UPDATE` statements. However they still need to be
> included in `SELECT` statements.
>
> The proposal therefore is to add a `readonly` option to the base `Field`
> class that when `True` would strip these fields from being compiled to
> SQL during `INSERT`s and `UPDATE`s. This allows for a very simple change
> that covers all possible write queries that Django may perform (including
> bulk_*).
>
> There exists a proof of concept https://github.com/novafloss/django-
> readonly-field

New description:

 There exist multiple use cases where a database will generate values for a
 field/column. Most RDBMSes expect that these columns be excluded from from
 `INSERT` and `UPDATE` statements. However they still need to be included
 in `SELECT` statements.

 Examples include the PostgreSQL `serial` data type, triggers and functions
 that generate defaults on `INSERT` (such as PostgreSQL `UUID`)

 The proposal therefore is to add a `readonly` option to the base `Field`
 class that when `True` would strip these fields from being compiled to SQL
 during `INSERT`s and `UPDATE`s. This allows for a very simple change that
 covers all possible write queries that Django may perform (including
 bulk_*).

 There exists a proof of concept https://github.com/novafloss/django-
 readonly-field

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27446#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 [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/065.3bf66741e07c111f9f8767d9bc265c18%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to