som types fixes, fix for wrong prefixes in model_row for complex relations, test load_all with repeating tables, add docs
This commit is contained in:
@ -124,7 +124,8 @@ async def create_user(user: User):
|
||||
|
||||
@app.post("/users2/", response_model=User)
|
||||
async def create_user2(user: User):
|
||||
return (await user.save()).dict(exclude={"password"})
|
||||
user = await user.save()
|
||||
return user.dict(exclude={"password"})
|
||||
|
||||
|
||||
@app.post("/users3/", response_model=UserBase)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from typing import Any, List, Sequence, cast
|
||||
from typing import Any, Sequence, cast
|
||||
|
||||
import databases
|
||||
import pytest
|
||||
|
||||
@ -108,3 +108,17 @@ async def test_model_multiple_instances_of_same_table_in_schema():
|
||||
assert len(classes[0].dict().get("students")) == 2
|
||||
assert classes[0].teachers[0].category.department.name == "Law Department"
|
||||
assert classes[0].students[0].category.department.name == "Math Department"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_load_all_multiple_instances_of_same_table_in_schema():
|
||||
async with database:
|
||||
await create_data()
|
||||
math_class = await SchoolClass.objects.get(name="Math")
|
||||
assert math_class.name == "Math"
|
||||
|
||||
await math_class.load_all(follow=True)
|
||||
assert math_class.students[0].name == "Jane"
|
||||
assert len(math_class.dict().get("students")) == 2
|
||||
assert math_class.teachers[0].category.department.name == "Law Department"
|
||||
assert math_class.students[0].category.department.name == "Math Department"
|
||||
|
||||
Reference in New Issue
Block a user