Remove legacy masoniteorm.backup + document ORM query-scopes state#164
Merged
Conversation
Delete the unused masoniteorm.backup duplicate (59 tracked files) that no longer had any importers across the monorepo, and drop its now-stale entry from pytest norecursedirs in pyproject.toml.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Task #774 — three parts: (1) document the ORM query-scopes feature and its state, (2) remove the legacy
masoniteorm.backupduplicate, (3) investigateLoader.py.1. Query-scopes feature — how it works & current state
Scopes live in the current ORM (
masoniteorm/models/), not in a dedicatedscopes/package:Model._global_scopes = {}(models/model.py). OnQueryBuilder.set_model()the dict is copied onto the builder (_global_scopes = model._global_scopes), and it's propagated to derived builders (e.g. the aggregate/count builder).{action: {name: callable}}, keyed by action (select,update, …). There is no public API to register a scope — noadd_global_scope(), noscope_*method discovery/boot._global_scopesis only ever initialised to{}, so in practice no global scope is ever populated.QueryBuilder.run_scopes()iteratesself._global_scopes.get(self._action, {})and calls eachscope(self). It runs fromto_sql()andto_qmark()(i.e. at compile time).get()still has a literal# TODO: apply scopes.without_global_scopes()— called but never defined. It's invoked in 5 places inrelationships/BelongsToMany.py(pivot select/attach/create paths), but no definition exists anywhere in the monorepo. Those pivot code paths would raiseAttributeErrorif reached with the current builder.State: partial / non-functional. The plumbing (
_global_scopes,run_scopes) is in place, but there is no registration API, no localscope_*support, andwithout_global_scopes()is missing — so the feature is effectively inert and theBelongsToManycalls are latent bugs. A follow-up task is recommended to either implementwithout_global_scopes()+ a registration API, or remove the dead scope plumbing and theBelongsToManycalls.2. Removed legacy
masoniteorm.backupscopes/,tests/,testing/.src,tests,example/*,application/,pyproject.toml) — nothing imports it. Its only reference wasnorecursedirsinpyproject.toml.norecursedirsentry.3.
Loader.pyinvestigationLoader.pyexists undermasoniteorm/. The twoLoader.pyfiles areloader/Loader.pyandfacades/Loader.py.loader/Loader.pyis actively used — imported byconfiguration/Configuration.py(Loader().get_modules(...)/get_parameters(...)) and exercised in tests. Kept — deleting it would break config loading.Verification
uv run pytest --ignore=tests/masoniteorm/postgres --cov→ 1777 passed, 7 skipped, coverage 78.56% (≥ 68% threshold). Postgres suite skipped (needs a live DB).uv run ruff check→ all checks passed.uv run ruff format --check→ 470 files already formatted.