fix saving related with pk only model (#1297)
This commit is contained in:
32
tests/test_model_methods/test_save_related_pk_only.py
Normal file
32
tests/test_model_methods/test_save_related_pk_only.py
Normal file
@ -0,0 +1,32 @@
|
||||
import ormar
|
||||
import pytest
|
||||
|
||||
from tests.lifespan import init_tests
|
||||
from tests.settings import create_config
|
||||
|
||||
base_ormar_config = create_config()
|
||||
|
||||
|
||||
class A(ormar.Model):
|
||||
ormar_config = base_ormar_config.copy()
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
|
||||
|
||||
class B(ormar.Model):
|
||||
ormar_config = base_ormar_config.copy()
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
a = ormar.ForeignKey(A)
|
||||
|
||||
|
||||
create_test_database = init_tests(base_ormar_config)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_saving_related_pk_only():
|
||||
async with base_ormar_config.database:
|
||||
async with base_ormar_config.database.transaction(force_rollback=True):
|
||||
a = A()
|
||||
await a.save()
|
||||
await a.save_related(follow=True, save_all=True)
|
||||
Reference in New Issue
Block a user