feat: add ServiceError and detached-safe session factory
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -123,3 +123,16 @@ def test_pending_migrations_applied_in_order_once(tmp_path, monkeypatch):
|
||||
assert _user_version(engine) == 3
|
||||
migrate(engine) # re-run is a no-op
|
||||
assert applied == [2, 3]
|
||||
|
||||
|
||||
def test_rows_stay_readable_after_session_closes(tmp_path):
|
||||
# Services use per-operation sessions; rows they return must remain
|
||||
# readable after the originating session closes (expire_on_commit=False).
|
||||
settings = _tmp_settings(tmp_path)
|
||||
ensure_db(settings)
|
||||
factory = get_session_factory(get_engine(settings))
|
||||
with factory() as session:
|
||||
p = Project(name="x", path="/x")
|
||||
session.add(p)
|
||||
session.commit()
|
||||
assert p.name == "x" # would raise DetachedInstanceError without the flag
|
||||
|
||||
Reference in New Issue
Block a user