paulocheque / django-dynamic-fixture

A complete library to create dynamic model instances for testing purposes.
http://django-dynamic-fixture.readthedocs.io/
Other
391 stars 67 forks source link

Force insert on G #140

Closed vishes-shell closed 3 years ago

vishes-shell commented 3 years ago

Can we eliminate redundant UPDATE on ddf.G()?

Simple order of ddf.G() is:

  1. DynamicFixture.get()
  2. DynamicFixture._save_the_instance()
  3. Model.save()
  4. sql UPDATE
  5. sql INSERT

Can we somehow remove step 4. by passing force_insert=True into Model.save() method? And if not, why?

I believe we can supply library with options to achieve that:

  1. DDF_FORCE_INSERT setting (with False by default)
  2. force_insert=False kwargs for DynamicFixture.get()
  3. teach with force_insert
vishes-shell commented 3 years ago

I believe there is no value since in django 3.2 it works as desired.