Hi all, I am at PyCon DE 2022 in Berlin with Markus and I shared with him this idea that I have been thinking about for a few months, given his interest I also share it with you.
I figured we could add in Django a "GeneratedField" which accepts a "base_field" attribute in a similar way to "ArrayField" and then an expression to generate a value for the field. For example this model: class Album(models.Model): ... title = models.CharField(max_length=120) search = GeneratedField( SearchVectorField(), F('title') ) would generate an SQL code like this in PostgreSQL: CREATE TABLE album ( ... title char(120), search tsvector GENERATED ALWAYS AS title STORED ); I found some documentation for different database backend about generated column (or similar names) # SQLite https://www.sqlite.org/gencol.html https://www.sqlite.org/releaselog/3_31_0.html # PostgreSQL https://www.postgresql.org/docs/12/ddl-generated-columns.html https://www.postgresql.org/docs/12/release-12.html # Oracle https://oracle-base.com/articles/11g/virtual-columns-11gr1 # MySQL https://dev.mysql.com/doc/refman/5.7/en/mysql-nutshell.html https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html # MariaDB https://mariadb.com/kb/en/changes-improvements-in-mariadb-102/ https://mariadb.com/kb/en/generated-columns/ I'd love to hear your thoughts on this idea and if you think it might be something worth continuing to investigate. Greetings from PyCon DE 2022 in Berlin, Paolo -- https://www.paulox.net -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAKFO%2Bx5GHUEVdzi2awYtH5C17tTPTPh%2ByoDP%3DKC18pF8%2Bi_7PA%40mail.gmail.com.