Repository navigation
Fewer false N+1, drift and migration alarms on real projects.
Fixed
-
migration-risk: treat annotated or partly computed
dependenciesas unknown
(#280).
Annotated assignments (dependencies: list = get_dependencies()) and
lists containing computed pairs ([("shop", get_parent())]) are now marked
dependencies_unknown, while recognizingswappable_dependency(...)as a
known dependency element, preventing false conflicting leaf reports. -
diff: read the
list --format jsondump its help documents.
list --format jsonwrites a flat[{app, model}]array, but_index_models
only understood{"apps": [...]}. Both sides indexed as empty, so two dumps
that differ printedNo schema changes.and exited 0. The list shape is now
read and reports the model additions/removals that format contains. When
only one side is a list dump, the diff stops at model level: marking every
field of the other side as removed would be false. -
Docs:
--path/--excludeand the MCP tool list
(#282).
The READMEs said every command takes--pathand--exclude;stats-sql
andmcptake neither, and the READMEs now say so. The Russian, Spanish and
Chinese READMEs listed ten MCP tools; they now list all fourteen, as the
English one does. -
parser: recognise aliased Django model roots and key inheritance cycles by (file, class)
(#281).
An imported alias ofdjango.db.models.Model(e.g.from django.db.models import Model as DjangoModel)
is now resolved as a model root before workspace mixin suppression, preventing subclasses of
workspace mixins from dropping out of the model list. In addition, abstract base cycle detection
is now keyed on(file, class)rather than bare class name, so an abstract mixin extending a
same-named mixin in another module no longer drops inherited fields. -
nplusone:
Prefetch(..., queryset=...select_related(...))covers the inner loop.
Prefetch("items", queryset=OrderItem.objects.select_related("product"))loads
items__producttoo, but only theitemslookup was recorded, so a loop over
order.items.all()readingitem.productwas reported as N+1 although the view
runs two queries. The inline queryset'sselect_related/prefetch_relatedpaths
now count under the lookup. A queryset held in a variable, or aPrefetchwith
to_attr, is still not followed. -
impact: report the column of the reference, not of an earlier prefix.
scan_file_textsearched for the bare needle to find the column, so a line
likeauthors = ...; book.author.namepointed atauthors(column 0)
instead of theauthorreference at column 37. The column now comes from
the same word-boundary match that accepted the line. -
Count the fields Django's auth bases give a custom user model
(#267).
A model built onAbstractBaseUser,PermissionsMixinorAbstractUser
now inherits their fields (password,last_login,is_superuser,
groups,user_permissions, and the profile fields ofAbstractUser) in
both parsers, sodriftno longer reports them as migrated but no longer
declared. A workspace class with the same name still wins, a field the
model sets toNone(username = None) stays removed, and an abstract
parent's own field now overrides the same field from its ancestors. -
suggest-indexes: propose one index for a column sorted both ways.
order_by("created_at")andorder_by("-created_at")produced two
proposals,[created_at]and[-created_at]. A B-tree index answers the
sort in either direction, so the second was redundant write cost. The
order_by pass now dedupes on the bare column, including against a
filter-driven proposal on the same column. -
migration-risk: no leaf conflict when
dependenciesis computed
(#247).
A migration withdependencies = get_dependencies()was read as having no
dependencies, so its parent looked like a second leaf and a linear history
got a criticalconflicting_migration_leaves. Such a migration is now
markeddependencies_unknownand the leaf check stays silent for its app. -
VS Code rules DOL011 / DOL014 / DOL015 read past nested calls.
CharField(max_length=100, verbose_name=_("Name"), null=True)was never
matched: the rules scanned the call with([^()]*), which stops at the
paren inside_("Name"). i18n-wrapped fields escaped thenull=True,
missing-max_lengthandTextField(max_length=)checks. All three now use
the samereadCallArgshelper DOL013 already used. -
Parser: models in a sub-package keep their app's label
(#266).
io_storages/s3/models.pywas labelleds3; the CLI now walks up through
packages to the directory withmigrations/orapps.py, so it is
io_storages.S3ImportStorage, as Django calls it, anddriftno longer
reports it as undeclared. The VS Code parser still uses the old rule. -
Parser: ignore Django field examples inside model docstrings. Both the
CLI and VS Code now keep those examples out of the model's field list. -
suggest-indexes: skip composites over a unique column
(#269).
A combo containing the primary key, aunique=Truefield or a
OneToOneFieldis no longer proposed: equality on that column already
returns at most one row, so the rest of the index never pays for its
writes.db_index=Truefields stay eligible. -
migration-risk: no more
app.Nonein text output for graph-level findings
(#268).
conflicting_migration_leaves/alembic_multiple_headsnow print
(migration graph) shopinstead ofshop.None. -
suggest-indexes: only propose indexes on local columns
(#252).
Many-to-many and reverse relation lookups still appear in usage counts,
but no longer produce invalidMeta.indexessuggestions. Django field imports
that use an alias keep their original field type in both parsers. -
Recognize directly imported Django field types (#250).
The CLI and VS Code parsers now recognizeGeneratedFieldand PostgreSQL
fields such asArrayField,HStoreField, range fields, and
SearchVectorField. Schema drift checks can now match those declarations
to their migrations. -
Workspace Mixin classes are no longer guessed to be models
(#249). Any base
whose name ended inMixinused to count as a Django model base, so plain
helpers (QuerySets, URL mixins) were reported as models anddriftfailed
with "declared, but no migration creates it". A base is now resolved
through its module's imports — including aliases — before the suffix guess
is used, and a class dropped as a known non-model (models.QuerySet,
models.Manager, ...) also stops its subclasses from becoming models. A
real abstract mixin is still found through itsmodels.Modelbase, and a
third-party*Mixinthe scanner cannot see keeps the guess. -
Abstract bases with the same class name are matched by
(file, name),
not bare name (#249).
When two apps defined a base with the same class name, a model could
inherit from whichever same-named base was seen first because the other
base was treated as already known. Bases are now identified by the file
their import resolves to, so a model inherits the fields of its own app's
base instead of another app's. -
nplusone: no
select_relatedfor a scalar when the loop's model is
unknown (#251).
for e in self.events.all(): e.date_from.astimezone(tz)was guessed to be a
foreign key and got.select_related("date_from"), which Django rejects. A
name that is a scalar on every model that has it is now skipped. A name that
is a relation on at least one model, or on none, is still guessed at
medium. -
signals: read the
signal=argument to@receiver. Single signals and
lists/tuples passed by keyword now retain their names and built-in markers
instead of appearing as<unknown>custom edges (#248). -
signals: resolve aliased
receiverimports. Imports such as
from django.dispatch import receiver as onandimport django.dispatch as d
are now resolved when matching@receiverdecorators (#261). -
Migration files without a four-digit prefix are read
(#246).
Django loads every module inmigrations/whose name does not start with
_or~, so hand-inserted0162b_auto_...pyand legacy008_...pyfiles
are real migrations. orm-lens skipped them, which hid anAddFieldfrom
driftand split the graph into false conflicting leaves. They are now
loaded and ordered by their numeric prefix. -
drift:
state_operationsbound inside theMigrationclass is resolved
(#245).
SeparateDatabaseAndState(state_operations=state_operations)with the list
on the class, as Django's docs write it, was dropped, so itsCreateModel
never counted anddriftblocked on a migrated model.