When attempting to deploy to Fly.io, the deployment fails with the error:
django.db.utils.ProgrammingError: generation expression is not immutable
which causes the the release command to fail. It looks like the GeneratedField is the culprit. If I remove the GeneratedField, the app deploys without error. According the the Model Field Reference, " PostgreSQL requires functions and operators referenced in a generated column to be marked as IMMUTABLE ." Is there a way to successfully use a GeneratedField with Postgres?
PostgreSQL requires functions and operators referenced in a generated column to be marked as IMMUTABLE. Unfortunately, PostgreSQL’s CONCAT is not considered an immutable, that’s why in Django 5.1 we’ve changed the implementation of Django’s Concat() to use ||
Thanks for the info – certainly answers my question. Are you aware of a workaround pending the release of 5.1? I’m one of those “non-expert users” to whom Paolo refers.
Gentlemen, thank you so much for your help. I’ve tried both solutions. The good news is both do solve the deployment problem – the app deploys without error. However, when saving a model instance that uses a GeneratedField (using the Django Admin), I get a new error:
IntegrityError at /admin/art/artist/add/
null value in column "full_name" of relation "art_artist" violates not-null constraint
DETAIL: Failing row contains (10, Pablo, null, Picasso, null, 1889, Spanish).
Request Method: POST
Request URL: http://curated-arts.fly.dev/admin/art/artist/add/
Django Version: 5.0.1
Exception Type: IntegrityError
Exception Value:
null value in column "full_name" of relation "art_artist" violates not-null constraint
DETAIL: Failing row contains (10, Pablo, null, Picasso, null, 1889, Spanish).
Exception Location: /usr/local/lib/python3.12/site-packages/psycopg/cursor.py, line 732, in execute
Raised during: django.contrib.admin.options.add_view
Python Executable: /usr/local/bin/python
Python Version: 3.12.1
Python Path:
['/code',
'/usr/local/bin',
'/usr/local/lib/python312.zip',
'/usr/local/lib/python3.12',
'/usr/local/lib/python3.12/lib-dynload',
'/usr/local/lib/python3.12/site-packages']
Server time: Sat, 20 Jan 2024 20:56:41 +0000
I assume the not null constraint is a default setting for GeneratedField? Is there a way to remove the not null constraint?