From 68b692e11b6a53abb74855a8e244b91d731c3fb6 Mon Sep 17 00:00:00 2001 From: collerek Date: Sun, 21 Mar 2021 15:48:12 +0100 Subject: [PATCH] fix coverage and add more info in release --- docs/releases.md | 7 ++++++- tests/test_load_all.py | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/releases.md b/docs/releases.md index cb993d5..1d3c5a9 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -5,7 +5,7 @@ * Dropped supported for long deprecated notation of field definition in which you use ormar fields as type hints i.e. `test_field: ormar.Integger() = None` * Improved type hints -> `mypy` can properly resolve related models fields (`ForeignKey` and `ManyToMany`) as well as return types of `QuerySet` methods. Those mentioned are now returning proper model (i.e. `Book`) instead or `ormar.Model` type. There is still problem with reverse sides of relation and `QuerysetProxy` methods, - to ease type hints now those return `Any`. + to ease type hints now those return `Any`. Partially fixes #112. ## Features @@ -14,6 +14,11 @@ By default `select_all()` adds only directly related models, with `follow=True` also related models of related models are added without loops in relations. +## Internals + +* `ormar` fields are no longer stored as Classes in `Meta.model_fields` dictionary + but instead they are stored as instances. + # 0.9.9 ## Features diff --git a/tests/test_load_all.py b/tests/test_load_all.py index 1527dd1..0095654 100644 --- a/tests/test_load_all.py +++ b/tests/test_load_all.py @@ -209,6 +209,18 @@ async def test_loading_nested(): assert hq2.nicks[1].level.name == "Low" assert hq2.nicks[1].level.language.name == "English" + hq5 = await HQ.objects.select_all().get(name="Main") + assert len(hq5.nicks) == 2 + await hq5.nicks.select_all(follow=True).all() + assert hq5.nicks[0] == nick1 + assert hq5.nicks[0].name == "BazingaO" + assert hq5.nicks[0].level.name == "High" + assert hq5.nicks[0].level.language.name == "English" + assert hq5.nicks[1] == nick2 + assert hq5.nicks[1].name == "Bazinga20" + assert hq5.nicks[1].level.name == "Low" + assert hq5.nicks[1].level.language.name == "English" + await hq.load_all(follow=True, exclude="nicks__level__language") assert len(hq.nicks) == 2 assert hq.nicks[0].level.language is None