bump ver, some cleanup

This commit is contained in:
collerek
2020-11-16 13:10:03 +01:00
parent d478ea6e15
commit 1168159a70
4 changed files with 20 additions and 8 deletions

View File

@ -359,8 +359,8 @@ But you can specify the `follow=True` parameter to traverse through nested model
So if you have a diamond or circular relations types you need to perform the updates in a manual way.
```python
# in example like this the second Street (coming from Company) won't be save_related, so Whatever won't be updated
Street -> District -> City -> Companies -> Street -> Whatever
# in example like this the second Street (coming from City) won't be save_related, so ZipCode won't be updated
Street -> District -> City -> Street -> ZipCode
```
## Internals

View File

@ -30,7 +30,7 @@ class UndefinedType: # pragma no cover
Undefined = UndefinedType()
__version__ = "0.4.4"
__version__ = "0.5.0"
__all__ = [
"Integer",
"BigInteger",

View File

@ -234,7 +234,7 @@ class Model(NewBaseModel):
@staticmethod
async def _update_and_follow(
rel: "Model", follow: bool, visited: Set, update_count: int
rel: T, follow: bool, visited: Set, update_count: int
) -> Tuple[int, Set]:
if follow and rel.__class__ not in visited:
update_count = await rel.save_related(

View File

@ -161,15 +161,27 @@ async def test_saving_reversed_relation():
assert hq.companies[0].saved
assert hq.companies[1].saved
hq = await HQ.objects.select_related(
["companies", "companies__hq__nicks"]
).get(name="Main")
hq.companies[0].hq.nicks[0].name = "Sub"
assert not hq.companies[0].hq.nicks[0].saved
await hq.save_related(follow=True)
assert not hq.companies[0].hq.nicks[0].saved
@pytest.mark.asyncio
async def test_saving_nested():
async with database:
async with database.transaction(force_rollback=True):
level = await CringeLevel.objects.create(name='High')
level2 = await CringeLevel.objects.create(name='Low')
nick1 = await NickNames.objects.create(name="BazingaO", is_lame=False, level=level)
nick2 = await NickNames.objects.create(name="Bazinga20", is_lame=True, level=level2)
level = await CringeLevel.objects.create(name="High")
level2 = await CringeLevel.objects.create(name="Low")
nick1 = await NickNames.objects.create(
name="BazingaO", is_lame=False, level=level
)
nick2 = await NickNames.objects.create(
name="Bazinga20", is_lame=True, level=level2
)
hq = await HQ.objects.create(name="Main")
assert hq.saved