Skip to content

Transaction improvement #1054

@Qiwn

Description

@Qiwn

Transaction only considers the objects in pg, it doesn't consider those objects are not stored in pg yet (they are in txn.deleted/added dict). It would be great if this kind of cases are contemplated:

async def test_txn_add_and_delete(container_requester):
    async with container_requester as requester:
        async with transaction(db=requester.db) as txn:
            root = await txn.get(ROOT_ID)
            container = await root.async_get("guillotina")
            await create_content_in_container(
                container, "Item", "foobar", check_security=False, __uuid__="foobar"
            )
            await container.async_del("foobar")
            obj = await container.async_get("foobar")  # should be deleted at this point
            assert obj is None

        async with transaction(db=requester.db) as txn:
            obj = await container.async_get("foobar")
            # object still exists
            assert obj is None

Another case: #1053

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions