﻿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
34943	Support passing database expressions to bulk_create()'s unique_fields.	Alex Vandiver	nobody	"#31685 added support for `INSERT ... ON CONFLICT(col1, col2) DO UPDATE SET ...`  In some cases, however, the unique constraint may be on computed columns, which cannot be used with `unique_fields` because they are directly quoted.

For instance:
{{{#!python
from django.db.models.functions import Upper
UserTopic.objects.bulk_create(
  [ut],
  update_conflicts=True,
  update_fields=['last_updated','visibility_policy'],
  unique_fields=['user_profile_id','stream_id',Upper('topic_name')],
)
}}}
...fails because `UserTopic has no field named 'Upper(F(topic_name))'`.

And:
{{{#!python
UserTopic.objects.bulk_create(
  [ut],
  update_conflicts=True,
  update_fields=['last_updated','visibility_policy'],
  unique_fields=['user_profile_id','stream_id','upper(topic_name)'],
)
}}}
...fails similarly, with `UserTopic has no field named 'upper(topic_name)'`.

It would be a useful feature to be able to handle these cases."	New feature	new	Database layer (models, ORM)	dev	Normal			Vitor Pereira Chih Sean Hsu	Accepted	0	0	0	0	0	0
