jeancochrane / jeancochrane/pytest-flask-sqlalchemy

Undesired `session.expire_all` leads to n+1 in tests

Open
#33 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
253
Forks
45
PR merge metrics
No merged PRs in 30d

Description

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:
```python
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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.