Skip to content

Undesired session.expire_all leads to n+1 in tests #33

@POD666

Description

@POD666

I have covered an endpoint with a test that counts DB queries and reveled n+1 issue.
The n+1 issue is only reproduced in tests so it seems to be related to this line (also if I remove this line the test pass):
https://github.com/jeancochrane/pytest-flask-sqlalchemy/blob/master/pytest_flask_sqlalchemy/fixtures.py#L59

In my app.py, I set following session_options:

db = SQLA(session_options={"autocommit": False, "autoflush": False, "expire_on_commit": False})

I guess, expire_on_commit option should be considered in the restart_savepoint function before expiring all objects.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions