paulocheque / django-dynamic-fixture

A complete library to create dynamic model instances for testing purposes.
http://django-dynamic-fixture.readthedocs.io/
Other
391 stars 67 forks source link

Support for Generated Columns (Postgres 12) with SearchVectorField #133

Closed spirkaa closed 4 years ago

spirkaa commented 4 years ago

django==2.2.13 django-dynamic-fixture==3.1.0

Generated Columns are introduced with Postgres 12.

A generated column cannot be written to directly. In INSERT or UPDATE commands, a value cannot be specified for a generated column, but the keyword DEFAULT may be specified.

Current version of DDF is incompotible with this type of fields, because even with DDF_IGNORE_FIELDS = ['search_vector'] there is instert of None in this field. This field must be excluded altogether from generated SQL or keyword DEFAULT must be used.

args = ('INSERT INTO "myapp_organisation" ("created", "modified", "name", "search_vector") VALUES (%s, %s, %s, %s) RETURNING "...(datetime.datetime(2020, 6, 19, 18, 30, 41, 249585), datetime.dat
etime(2020, 6, 19, 18, 30, 41, 249598), 'test', None))`
`django_dynamic_fixture.ddf.BadDataError: ('apps.myapp.models.Organisation', ProgrammingError('cannot insert into column "search_vector"\nDETAIL:  Column "search_vector" is a generated column.\n'))
spirkaa commented 4 years ago

Oops, Django itself doesn't support this fields by now https://code.djangoproject.com/ticket/31300

Sorry to bother