Skip to content

Commit

Permalink
Added test case to test fk update to none
Browse files Browse the repository at this point in the history
  • Loading branch information
amit12297 committed Dec 6, 2023
1 parent 7c2954d commit ccbcd41
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_relations/test_foreign_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,15 @@ async def test_bulk_update_model_with_children():
is_best_seller=True
).all()
assert len(best_seller_albums_db) == 2


@pytest.mark.asyncio
async def test_fk_update_to_none():
async with database:
async with database.transaction(force_rollback=True):
fantasies = await Album.objects.create(name="Limitless")
track = await Track.objects.create(album=fantasies, title="Test1", position=1)
assert track.album.name == "Limitless"
track.album = None
updated_track = await track.update(_columns=["album"])
assert updated_track.album is None

0 comments on commit ccbcd41

Please sign in to comment.