Skip to content

[docs][database] Sessions/mixins docs reference APIs that don't exist (engine_for, DatabaseState.session, before_compile/insert/update/delete listeners, no_tenant/skip_tenant_filter) + wrong AuditMixin types #197

Description

@antosubash

Summary

docs/database/sessions.md and docs/database/mixins.md describe an API that isn't in v0.0.17.

Environment

  • Framework checkout: v0.0.17-5-g2b079c9; smpy / published simple_module_* / @simple-module-py/*: 0.0.17
  • Python 3.12.3, uv 0.11.7, node v24.15.0, Linux (Ubuntu)

Found while building a real consumer app (Invoice Manager) on the framework.

Evidence vs. code

  • sessions.md shows engine_for(...) and DatabaseState.session() — neither exists. Real: get_db reads request.app.state.sm.db.session_factory; out-of-request code uses async with db_state.session_factory() as session: (and init_db(...) does NOT auto-register entity listeners — callers do register_listeners(state), as the root conftest.py does).
  • mixins.md describes before_compile / before_insert / before_update / before_delete listeners and no_tenant() / skip_tenant_filter=True escape hatches — none exist. Real impl is a single before_flush listener + a do_orm_execute hook with with_loader_criteria; the only escape hatch is stmt.execution_options(include_deleted=True).
  • mixins.md documents AuditMixin.created_by/updated_by as int | None from request.state.principal.user_id; real columns are str | None, stamped from the current_user_id ContextVar.

Impact

Consumers can't write out-of-request DB code (seeders, scripts) or reason about tenant/soft-delete bypass from the docs. Suggest aligning these two docs with the real simple_module_db API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions