Skip to content

db: ORM restore (is_deleted True→False) and ORM primary-key changes leave no audit record #811

Closed

Description

@antosubash

Summary

Two ORM changes leave no audit record at all:

  • Restore: setting a trashed row's is_deleted from True to False and flushing. Soft-delete columns are excluded from ordinary diffs, and the lifecycle branch only handles is_deleted=True.
  • Primary-key change: assigning a new PK to a loaded object and flushing. _column_diffs excludes primary keys on UPDATE as well as on create.

The statement-DML paths for both already produce records. Only the unit-of-work path misses them.

Where

  • framework/db/simple_module_db/audit.py:203 (restore)
  • framework/db/simple_module_db/audit.py:125 (PK diff)

Reproduction

  • Restore: with audited, add and flush SoftDeleteItem(title="x", is_deleted=True), clear the recorder, set is_deleted=False, flush. Result: recorder.records == [].
  • PK change: load an AuditTestItem, set id=999, flush. Result: no record.

Suggested fix

Emit a restored lifecycle record when is_deleted goes from True to False, matching the DML path. Include the PK old/new pair in UPDATE diffs (exclude PKs only on create).

Found in a full review of simple_module_db (main @ 7a5c860).

Activity

  1. antosubash commented on Nov 4, 2026

    @antosubash
    OwnerAuthor

    Fixed in #821 (squash-merged as 0fcd877).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions