create_or_update
does not allow for specifying what unique fields to match
#828
Labels
create_or_update
does not allow for specifying what unique fields to match
#828
Problem
Currently, it is not possible to specify on what fields you want to apply the merge action when calling
create_or_update
. Meaning if you have aStructuredNode
with two unique fieldspk
andname
. And you want to update only based onname
(don't have access topk
). You can't really update all at once usingcreate_or_update
, or you need to resort to an ugly hack:Django's bulk_update has a similar feature, using
unique_fields
when callingbulk_create
withupdate_conflicts=True
.https://docs.djangoproject.com/en/5.1/ref/models/querysets/#bulk-create
Solution
It should be fairly simple to add a parameter to select which required properties to use. Backwards compatibility can be supported by using required_properties if parameter is not specified.
The text was updated successfully, but these errors were encountered: