@@ -248,6 +248,45 @@ def test_save11_load():
248
248
obj = save11_Comment .objects .first ()
249
249
SINK (obj .text ) # $ MISSING: flow
250
250
251
+ # --------------------------------------
252
+ # <Model>.objects.bulk_create()
253
+ # see https://docs.djangoproject.com/en/4.0/ref/models/querysets/#bulk-create
254
+ # --------------------------------------
255
+ class TestSave12 (models .Model ):
256
+ text = models .CharField (max_length = 512 )
257
+
258
+ def test_save12_store ():
259
+ objs = TestSave12 .objects .bulk_create ([
260
+ TestSave12 (text = SOURCE ),
261
+ TestSave12 (text = "foo" ),
262
+ ])
263
+ SINK (objs [0 ].text ) # $ MISSING: flow
264
+
265
+ def test_save12_load ():
266
+ obj = TestSave12 .objects .first ()
267
+ SINK (obj .text ) # $ MISSING: flow
268
+
269
+ # --------------------------------------
270
+ # <Model>.objects.bulk_update()
271
+ # see https://docs.djangoproject.com/en/4.0/ref/models/querysets/#bulk-update
272
+ # --------------------------------------
273
+ class TestSave13 (models .Model ):
274
+ text = models .CharField (max_length = 512 )
275
+
276
+ def test_save13_init ():
277
+ obj = TestSave13 (text = "foo" )
278
+ obj .save ()
279
+
280
+ def test_save13_store ():
281
+ objs = TestSave13 .objects .all ()
282
+ for obj in objs :
283
+ obj .text = SOURCE
284
+ TestSave13 .objects .bulk_update (objs , ["text" ])
285
+
286
+ def test_save13_load ():
287
+ obj = TestSave13 .objects .first ()
288
+ SINK (obj .text ) # $ MISSING: flow
289
+
251
290
# ------------------------------------------------------------------------------
252
291
# Different ways to load data from the DB through the ORM
253
292
# ------------------------------------------------------------------------------
@@ -319,6 +358,14 @@ def test_load_values_list():
319
358
SINK (text ) # $ MISSING: flow
320
359
SINK (vals [0 ]) # $ MISSING: flow
321
360
361
+ def test_load_in_bulk ():
362
+ # see https://docs.djangoproject.com/en/4.0/ref/models/querysets/#in-bulk
363
+ d = TestLoad .objects .in_bulk ([1 ])
364
+ for val in d .values ():
365
+ SINK (val .text ) # $ MISSING: flow
366
+ SINK (d [1 ].text ) # $ MISSING: flow
367
+
368
+
322
369
# Good resources:
323
370
# - https://docs.djangoproject.com/en/4.0/topics/db/queries/#making-queries
324
371
# - https://docs.djangoproject.com/en/4.0/ref/models/querysets/
0 commit comments