jeancochrane / jeancochrane/pytest-flask-sqlalchemy

Nested transactions with db_session

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

Description

Can anyone clarify if it is expected behavior? It seems like nested transactions don't work and I'm not sure if it should be fixed or not.

```python
def test_rollback_nested(person, db_session):
assert db_session.query(person).count() == 0
n1 = db_session.begin_nested()
db_session.add(person())
assert db_session.query(person).count() == 1
n2 = db_session.begin_nested()
db_session.add(person())
assert db_session.query(person).count() == 2
n2.rollback()
assert db_session.query(person).count() == 1 # Fails, we have 2 records in db
n1.rollback()
assert db_session.query(person).count() == 0
```

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.