diff --git a/README.md b/README.md index d196550..fac2862 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,10 @@ Ormar - apart form obvious ORM in name - get it's name from ormar in swedish whi And what's a better name for python ORM than snakes cabinet :) +**If you like ormar remember to star the repository in [github](https://github.com/collerek/ormar)!** + +The bigger community we build, the easier it will be to catch bugs and attract contributors ;) + ### Documentation Check out the [documentation][documentation] for details. @@ -73,7 +77,7 @@ Ormar is built with: `ormar` is built as an open-sorce software and remain completely free (MIT license). As I write open-source code to solve everyday problems in my work or to promote and build strong python -community you can say thank you and buy me a coffee or sponsor me with a monthly amount to help me ensure my work remains free and maintained. +community you can say thank you and buy me a coffee or sponsor me with a monthly amount to help ensure my work remains free and maintained. diff --git a/docs/index.md b/docs/index.md index d196550..fac2862 100644 --- a/docs/index.md +++ b/docs/index.md @@ -35,6 +35,10 @@ Ormar - apart form obvious ORM in name - get it's name from ormar in swedish whi And what's a better name for python ORM than snakes cabinet :) +**If you like ormar remember to star the repository in [github](https://github.com/collerek/ormar)!** + +The bigger community we build, the easier it will be to catch bugs and attract contributors ;) + ### Documentation Check out the [documentation][documentation] for details. @@ -73,7 +77,7 @@ Ormar is built with: `ormar` is built as an open-sorce software and remain completely free (MIT license). As I write open-source code to solve everyday problems in my work or to promote and build strong python -community you can say thank you and buy me a coffee or sponsor me with a monthly amount to help me ensure my work remains free and maintained. +community you can say thank you and buy me a coffee or sponsor me with a monthly amount to help ensure my work remains free and maintained. diff --git a/tests/test_exclude_include_dict/test_pydantic_dict_params.py b/tests/test_exclude_include_dict/test_pydantic_dict_params.py index a6c33c9..474580e 100644 --- a/tests/test_exclude_include_dict/test_pydantic_dict_params.py +++ b/tests/test_exclude_include_dict/test_pydantic_dict_params.py @@ -69,29 +69,67 @@ async def test_exclude_default(): @pytest.mark.asyncio async def test_exclude_none(): async with database: - category = Category(name=None) + category = Category(id=2, name=None) assert category.dict() == { - "id": None, + "id": 2, "items": [], "name": None, "visibility": True, } - assert category.dict(exclude_none=True) == {"items": [], "visibility": True} + assert category.dict(exclude_none=True) == { + "id": 2, + "items": [], + "visibility": True, + } await category.save() category2 = await Category.objects.get() assert category2.dict() == { - "id": 1, + "id": 2, "items": [], "name": None, "visibility": True, } assert category2.dict(exclude_none=True) == { - "id": 1, + "id": 2, "items": [], "visibility": True, } assert ( category2.json(exclude_none=True) - == '{"id": 1, "visibility": true, "items": []}' + == '{"id": 2, "visibility": true, "items": []}' ) + + +@pytest.mark.asyncio +async def test_exclude_unset(): + async with database: + category = Category(id=3, name="Test 2") + assert category.dict() == { + "id": 3, + "items": [], + "name": "Test 2", + "visibility": True, + } + assert category.dict(exclude_unset=True) == { + "id": 3, + "items": [], + "name": "Test 2", + } + + await category.save() + category2 = await Category.objects.get() + assert category2.dict() == { + "id": 3, + "items": [], + "name": "Test 2", + "visibility": True, + } + # NOTE how after loading from db all fields are set explicitly + # as this is what happens when you populate a model from db + assert category2.dict(exclude_unset=True) == { + "id": 3, + "items": [], + "name": "Test 2", + "visibility": True, + }