Repository navigation
py-v1.16.0 - SQLAlchemy support: scan, ER diagrams and N+1 for SQLAlchemy models
·
13 commits
to main
since this release
Changed
- django-orm-lens is now orm-lens, and reads SQLAlchemy models.
The package isorm-lenson PyPI, with the commandsorm-lensand
orm-lens-mcpand the moduleorm_lens. Nothing written against the old
name breaks:pip install django-orm-lens(and[mcp]) installs the
matching orm-lens and keeps thedjango-orm-lens/django-orm-lens-mcp
commands andimport django_orm_lens, and upgrading an existing install
keeps both command names. The MCP server readsORM_LENS_ROOTand
ORM_LENS_ALLOWED_ROOTS, then the oldDJANGO_ORM_LENS_*names. The
repository moved togithub.com/FROWNINGdev/orm-lens(the old URLs
redirect), the docs tofrowningdev.github.io/orm-lens, the MCP Registry
entry toio.github.FROWNINGdev/orm-lens, and the image to
ghcr.io/frowningdev/orm-lens(ghcr.io/frowningdev/django-orm-lenskeeps
getting the same builds). Kept on purpose: the pre-commit hook ids, the
SARIF tool name (code scanning keys open alerts on it) and the blast-radius
PR-comment marker. The GitHub Action still accepts a pre-1.16version.
Added
- SQLAlchemy models: scan, ER diagrams and N+1 (preview).
scan,list,describe,hover,erandnplusone, and the matching
MCP tools, now read SQLAlchemy models: 2.0DeclarativeBase/Mapped[],
1.xdeclarative_base()/Column, Flask-SQLAlchemydb.Modeland
SQLModeltable=Trueclasses. Static as always:ast, no import, no
database. Bases and mixins are followed across files, table names come
from__tablename__or the base's naming rule, foreign keys become ER
edges, andrelationship()attributes are listed with their loader.
nplusoneflags a loop over query results that reads a lazy relationship
withoutselectinload/joinedloadin the query's options, and suggests
the option. The Django analyses (drift, blast radius, cascade, signals)
stay Django-only. Checked on Superset, Airflow, Prefect, Polar, Dispatch,
Mealie, CTFd, Redash and the FastAPI template: 12 N+1 findings, all real.
See docs/rules/sqlalchemy.md.
Fixed
- SQLAlchemy and Flask classes no longer pass for Django models. A
models.pywithclass User(db.Model)or Flask-AppBuilder'sModel
matched the parser'sModelheuristic, so a Flask project showed up as a
Django one: 65 phantom models in Superset, 138 in Polar, 69 in Dispatch.
Files that are SQLAlchemy code and never import Django are now left to
the SQLAlchemy reader. The Django projects in the census are unchanged.