﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24509	Allow Expressions when saving new models	Alex Hill	Josh Smeaton <josh.smeaton@…>	"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

Update: patch at https://github.com/django/django/pull/5099"	New feature	closed	Database layer (models, ORM)	dev	Normal	fixed		me@…	Ready for checkin	1	0	0	0	0	0
