#24509: Allow Expressions when saving new models ----------------------------------------------+-------------------- Reporter: AlexHill | Owner: nobody Type: New feature | Status: new Component: Database layer (models, ORM) | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------------------------+-------------------- Opening a ticket after discussion on IRC with Josh.
You can use `Expression` when updating models, but it would also be useful to be able to use them when creating models, particularly in order to apply database functions to newly-inserted values. My specific use case for this is a PostgreSQL `TSVectorField`, where instead of just inserting a value, I want to insert `strip(to_tsvector(<ts_config>, unaccent(<value>)))`. Ideally, I would be able to define these all as `Func`s and insert an `Expression`. I propose to fix this by making `SQLInsertCompiler` check for `resolve_expressions` and `as_sql`, as `SQLUpdateCompiler` does. Alex -- Ticket URL: <https://code.djangoproject.com/ticket/24509> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/051.1b12b093e709ea8263010af90db3500c%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.