Skip to content

Follow-ups from the v2.6.0 SQLModel/FastAPI review (#76) #77

Description

@jedymatt

Non-blocking items deferred by the final whole-branch review of #76, plus pre-existing nits it surfaced. None affect released behavior.

Hardening candidates

  • Residual util.get_model_class edge paths. First-class SQLModel & FastAPI support (v2.6.0) #76 fixed the kwargs-on-bare-Exception bug (TypeError instead of the intended errors), but two adjacent paths still leak raw exceptions: a valid module with a missing class name ("tests.models.NoSuchClass") raises raw AttributeError because the getattr sits outside the try, and a dotless path ("nodots") raises ValueError from the rsplit unpack. Fix: move the getattr into the try and catch ValueError on the split, so both raise InvalidModelPath/UnsupportedClassError with messages. Natural fit with the validator/seeder hardening line of work.
  • autoflush=False regression test for the FK-column filter flush. HybridSeeder._setup_filter_instance's column branch has an autoflush-gated flush() (a select() of a raw Core column skips the ORM autoflush legacy Query performed). Parity for autoflush=False sessions was verified manually during review but no test pins it — a ~10-line test would prevent someone later "simplifying" the gate away.

Cosmetic

  • Hoist the mid-file import unittest in tests/test_sqlmodel.py (~line 156) to the top imports (after the importorskip).
  • README "Works with SQLModel & FastAPI" example: add an # app/__init__.py (empty) breadcrumb — the example runs as-is via PEP 420 namespace packages, but real projects have the file.
  • Remove the stray module-level print(repr(val)) at the bottom of tests/models.py (fires on every test-suite import).

Context: PR #76 · v2.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions