def test_standalone_method_with_constraint(self, pet): django_pg_upsert.insert_conflict(pet, constraint="starwars_pet_name_key") django_pg_upsert.insert_conflict(pet, constraint="starwars_pet_name_key") self.assert_create_single_record()
def test_bulk_standalone_method(self): cat = models.Pet(age=8, name="cat") dog = models.Pet(age=12, name="dog") django_pg_upsert.insert_conflict([cat, dog]) django_pg_upsert.insert_conflict([cat, dog]) self.assert_two_records()
def test_standalone_method_update(self, pet): pet.save() pet.age = 100 django_pg_upsert.insert_conflict(pet, fields=["name"], update=["age"]) records = models.Pet.objects.all() assert len(records) == 1 assert len(records) == 1 pet.refresh_from_db() assert pet.age == 100 assert pet.name == "dog"
def test_bulk_standalone_method_update(self): cat = models.Pet(age=3, name="cat") dog = models.Pet(age=2, name="dog") cat.save() dog.save() cat.age = 8 cat.alias_name = "grogu" dog.age = 12 dog.alias_name = "yoda" django_pg_upsert.insert_conflict( [cat, dog], fields=["name"], update=["age", "alias_name"] ) records = self.assert_two_records() assert records[0].alias_name == "grogu" assert records[1].alias_name == "yoda"
def test_standalone_method_with_fields(self, pet): django_pg_upsert.insert_conflict(pet, fields=["name"]) self.assert_create_single_record()
def test_standalone_method(self, pet): django_pg_upsert.insert_conflict(pet) django_pg_upsert.insert_conflict(pet) self.assert_create_single_record()