#35350: Crash on write of new instance when using GeneratedField
-------------------------------------+-------------------------------------
     Reporter:  Matt Hegarty         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  5.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  GeneratedField       |             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 Matt Hegarty:

Old description:

> We have an [https://github.com/django-import-export/django-import-
> export/issues/1779 issue in django-import-export] where imports of new
> instances fails when the model has a GeneratedField.
>
> This occurs when an instance is being created which doesn't already exist
> in the database, which the
> [https://docs.djangoproject.com/en/5.0/ref/models/fields/#generatedfield
> docs] imply is supported by GeneratedField:
>
>   A stored generated column is computed when it is written (inserted or
> updated)
>
> The stack trace is attached.
>
> Steps to reproduce:
>
> 1.  Clone [https://github.com/matthewhegarty/django-import-
> export/tree/issue-1779-generatedfield this repo] and use the
> 'issue-1779-generatedfield' branch.
> 2.  Create a [https://django-import-
> export.readthedocs.io/en/4.0.0-rc.1/contributing.html#development venv]
> 3.  Install the example app following the instructions [https://django-
> import-export.readthedocs.io/en/4.0.0-rc.1/installation.html#example-app
> here]
> 4.  Navigate to "Books", click "Import", then select the attached
> sample.csv file.
> 5.  Click "Submit" and you will see the error.

New description:

 We have an [https://github.com/django-import-export/django-import-
 export/issues/1779 issue in django-import-export] where imports of new
 instances fails when the model has a GeneratedField.

 This occurs when an instance is being created which doesn't already exist
 in the database, which the
 [https://docs.djangoproject.com/en/5.0/ref/models/fields/#generatedfield
 docs] imply is supported by GeneratedField:

   A stored generated column is computed when it is written (inserted or
 updated)

 The stack trace is attached.

 Steps to reproduce:

 1.  Clone [https://github.com/matthewhegarty/django-import-
 export/tree/issue-1779-generatedfield this repo] and use the
 'issue-1779-generatedfield' branch.
 2.  Create a [https://django-import-
 export.readthedocs.io/en/4.0.0-rc.1/contributing.html#development venv]
 3.  Install the example app following the instructions [https://django-
 import-export.readthedocs.io/en/4.0.0-rc.1/installation.html#example-app
 here]
 4.  Navigate to "Books", click "Import", then select the attached
 sample.csv file.
 5.  Click "Submit" and you will see the error.

 * python 3.12
 * django 5.0.3

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35350#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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ea42ff4d7-5851f98d-b490-496d-a4a2-fd864959d893-000000%40eu-central-1.amazonses.com.

Reply via email to