@@ -253,6 +253,21 @@ def upsert_and_get(self, conflict_target: List, fields: Dict):
253
253
self .on_conflict (conflict_target , ConflictAction .UPDATE )
254
254
return self .insert_and_get (** fields )
255
255
256
+ def bulk_upsert (self , conflict_target : List , rows : List [Dict ]):
257
+ """Creates a set of new records or updates the existing
258
+ ones with the specified data.
259
+
260
+ Arguments:
261
+ conflict_target:
262
+ Fields to pass into the ON CONFLICT clause.
263
+
264
+ rows:
265
+ Rows to upsert.
266
+ """
267
+
268
+ self .on_conflict (conflict_target , ConflictAction .UPDATE )
269
+ return self .bulk_insert (rows )
270
+
256
271
def _build_insert_compiler (self , rows : List [Dict ]):
257
272
"""Builds the SQL compiler for a insert query.
258
273
@@ -484,6 +499,20 @@ def upsert_and_get(self, conflict_target: List, fields: Dict):
484
499
485
500
return self .get_queryset ().upsert_and_get (conflict_target , fields )
486
501
502
+ def bulk_upsert (self , conflict_target : List , rows : List [Dict ]):
503
+ """Creates a set of new records or updates the existing
504
+ ones with the specified data.
505
+
506
+ Arguments:
507
+ conflict_target:
508
+ Fields to pass into the ON CONFLICT clause.
509
+
510
+ rows:
511
+ Rows to upsert.
512
+ """
513
+
514
+ return self .get_queryset ().bulk_upsert (conflict_target , fields )
515
+
487
516
@staticmethod
488
517
def _on_model_save (sender , ** kwargs ):
489
518
"""When a model gets created or updated."""
0 commit comments