support(bulk-create): add raise_error flag when bulk-create empty models (#853)

* add raise_error flag when bulk-create empty models

* if not raise_error, return

* fix ut cov

* raise exception when it's empty
This commit is contained in:
Ethon
2022-09-28 18:54:49 +08:00
committed by GitHub
parent 3cb221bdde
commit fd0f40afd0
2 changed files with 7 additions and 0 deletions

View File

@ -286,6 +286,9 @@ async def test_bulk_create():
completed = await ToDo.objects.filter(completed=True).all()
assert len(completed) == 2
with pytest.raises(ormar.exceptions.ModelListEmptyError):
await ToDo.objects.bulk_create([])
@pytest.mark.asyncio
async def test_bulk_create_json_field():