fix: soft-delete via direct UPDATE + non-generator get_first #6

Merged
i.bahlai merged 1 commit from hotfix/delete-entity-commit into main 2026-04-05 12:40:44 +00:00
Owner

Two fixes for the soft-delete flow (delete_entity):

  1. get_first: replaced async-generator-based implementation with
    a direct session query. The generator-based approach kept the
    session open after returning the first result, causing connection
    leaks that blocked subsequent writes (especially on SQLite).

  2. soft_delete: new repo method that issues a direct
    UPDATE … SET remove=true with explicit commit, avoiding the
    ORM merge path on detached entities entirely.

  3. delete_entity: now calls repo.soft_delete(entity_id) instead
    of fetching, mutating a detached entity, and calling repo.update().

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

Two fixes for the soft-delete flow (delete_entity): 1. **get_first**: replaced async-generator-based implementation with a direct session query. The generator-based approach kept the session open after returning the first result, causing connection leaks that blocked subsequent writes (especially on SQLite). 2. **soft_delete**: new repo method that issues a direct `UPDATE … SET remove=true` with explicit commit, avoiding the ORM merge path on detached entities entirely. 3. **delete_entity**: now calls `repo.soft_delete(entity_id)` instead of fetching, mutating a detached entity, and calling `repo.update()`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fix: soft-delete via direct UPDATE + non-generator get_first
All checks were successful
CI Pipeline - Development / Code Quality Check (pull_request) Successful in 1m26s
CI Pipeline - Development / Run Tests (pull_request) Successful in 1m49s
3944c44f23
Two fixes for the soft-delete flow (delete_entity):

1. **get_first**: replaced async-generator-based implementation with
   a direct session query. The generator-based approach kept the
   session open after returning the first result, causing connection
   leaks that blocked subsequent writes (especially on SQLite).

2. **soft_delete**: new repo method that issues a direct
   `UPDATE … SET remove=true` with explicit commit, avoiding the
   ORM merge path on detached entities entirely.

3. **delete_entity**: now calls `repo.soft_delete(entity_id)` instead
   of fetching, mutating a detached entity, and calling `repo.update()`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
CobraPack/repository!6
No description provided.