Skip to content

meta(core): follow-ups to the isModelStatic cache from #18234 - #18559

Merged
WikiRik merged 6 commits into
mainfrom
wikirik-agent/model-utils-followups
Oct 20, 2026
Merged

WikiRik merged 6 commits into
mainfrom
wikirik-agent/model-utils-followups

Conversation

@wikirik-agent

@wikirik-agent wikirik-agent commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository? (not applicable)
  • Did you update the typescript typings accordingly (if applicable)? (not applicable)
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description of Changes

These came out of a review of #18234, which was merged before they could be pushed to it:

  • Explain the lazy require. The comment above cachedModelClass said "see isModelStatic below", but that explanation was removed. There is now a comment at the require('../model') call saying a static import breaks the module load order (it fails with Cannot access 'MultiAssociation' before initialization), so it's harder to "clean up" into a static import.
  • Fix the cache type. cachedModelClass holds the base Model class, which isn't a ModelStatic (isModelStatic(Model) === false). It's now typed typeof Model. The cast stays because require() returns any, and assigning any doesn't narrow away undefined.
  • Test the shadowing warning. fix(core): cache the Model class in isModelStatic to avoid repeated require() #18234 changed addAttributeGetterAndSetters to use the statically imported Model instead of a lazy require. The existing OverWrittenKeys test already covers that attributes don't overwrite built-ins, but the warning message itself had no test. The new one checks that defining an attribute named set logs it, and that an ordinary attribute doesn't.

Related: #18558 (separate import-order crash in decorators-legacy, found during the same review).

List of Breaking Changes

None.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added coverage confirming that defining an attribute with the same name as a built-in model property logs a warning. The test checks that the warning identifies the conflicting property and recommends renaming the attribute.
  • Refactor
    • Updated internal type annotations for model-class checks. Runtime behavior and caching remain unchanged; there are no changes to the public API.

wikirik-agent and others added 2 commits October 19, 2026 22:28
…ix its cache type

The cache holds the base Model class, which is not a ModelStatic.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wikirik-agent
wikirik-agent requested a review from a team as a code owner October 19, 2026 22:29
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: edaf0bd8-c63f-4ff6-8d30-526f47d5ed3b
📥 Commits

Reviewing files that changed from the base of the PR and between 94eed87 and 4f4a11f.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0533b861-7f7f-45c9-a688-05c195b21652
📥 Commits

Reviewing files that changed from the base of the PR and between b84c6df and 611b38a.

📒 Files selected for processing: 1
  • packages/core/src/utils/model-utils.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • packages/core/src/utils/model-utils.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

The lazy Model cache and require cast now use typeof Model. A test captures model-definition logs and checks the warning for an attribute named set.

Changes: Model behavior

Layer / File(s) Summary
Lazy Model cache type
packages/core/src/utils/model-utils.ts
The cache and lazy require cast use typeof Model. A comment explains that a static import would break module load order because of a cyclic import.
Built-in property warning test
packages/core/test/unit/model/overwriting-builtins.test.ts
A test captures logs during model definition and checks that the matching shadowing warning identifies the set attribute. The test restores the logger spy in a finally block.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 611b3

No merge-blocking issue is identified in these changes; merge after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the follow-up changes to the isModelStatic cache and links them to the related pull request. It is concise and relevant to the main changes.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

… call

Also narrows the shadowing test title to what it covers (a built-in method).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread packages/core/src/utils/model-utils.ts Resolved
@wikirik-agent wikirik-agent changed the title refactor(core): follow-ups to the isModelStatic cache from #18234 fix(core): follow-ups to the isModelStatic cache from #18234 Oct 19, 2026
@wikirik-agent wikirik-agent changed the title fix(core): follow-ups to the isModelStatic cache from #18234 meta(core): follow-ups to the isModelStatic cache from #18234 Oct 19, 2026
@WikiRik
WikiRik enabled auto-merge (squash) October 19, 2026 22:38
@WikiRik
WikiRik merged commit 76de3cc into main Oct 20, 2026
@WikiRik
WikiRik deleted the wikirik-agent/model-utils-followups branch October 20, 2026 01:33
papandreou added a commit to papandreou/sequelize that referenced this pull request Oct 23, 2026
* origin/main: (54 commits)
  fix: use bind parameters in the Oracle catalog queries (sequelize#18498)
  meta: update mysql docker tag to v8.4.13 (sequelize#18577)
  meta: update dependency eslint-plugin-jsdoc to v65.4.0 (sequelize#18575)
  meta: update dependency node to v24.22.1 (sequelize#18574)
  meta: update dependency @oclif/core to ^5.1.9 (sequelize#18573)
  fix(core): skip removing foreign keys in dropAllTables when dropping with cascade (sequelize#18497)
  fix(core): drop each model only once in Sequelize#drop (sequelize#18572)
  fix(postgres): drop the enum types of a model when its table is dropped (sequelize#18554)
  fix(core): avoid lodash omit in the Model constructor (sequelize#18556)
  meta(core): support async functions in expectPerDialect (sequelize#18569)
  meta: update dependency ibm_db to ^4.1.0 (sequelize#18571)
  fix(core): make rejectInvalidOptions iterate supportable options and accept undefined (sequelize#18557)
  fix(core): respect the omitNull option of calls and models, fix query generator typings (sequelize#18565)
  meta(core): convert unit/model tests to TypeScript (sequelize#18564)
  meta(core): convert unit/instance tests to TypeScript (sequelize#18563)
  meta: update sequelize AUTHORS (sequelize#18549)
  feat(mssql): add useUnicodeStrings dialect option (sequelize#18548)
  meta: retry image pulls in the database start scripts (sequelize#18340)
  meta(core): follow-ups to the isModelStatic cache from sequelize#18234 (sequelize#18559)
  meta: update dependency uuid to v14 (sequelize#18544)
  ...

# Conflicts:
#	packages/postgres/src/query-interface.js
papandreou added a commit to papandreou/sequelize that referenced this pull request Oct 23, 2026
* origin/main: (26 commits)
  fix: use bind parameters in the Oracle catalog queries (sequelize#18498)
  meta: update mysql docker tag to v8.4.13 (sequelize#18577)
  meta: update dependency eslint-plugin-jsdoc to v65.4.0 (sequelize#18575)
  meta: update dependency node to v24.22.1 (sequelize#18574)
  meta: update dependency @oclif/core to ^5.1.9 (sequelize#18573)
  fix(core): skip removing foreign keys in dropAllTables when dropping with cascade (sequelize#18497)
  fix(core): drop each model only once in Sequelize#drop (sequelize#18572)
  fix(postgres): drop the enum types of a model when its table is dropped (sequelize#18554)
  fix(core): avoid lodash omit in the Model constructor (sequelize#18556)
  meta(core): support async functions in expectPerDialect (sequelize#18569)
  meta: update dependency ibm_db to ^4.1.0 (sequelize#18571)
  fix(core): make rejectInvalidOptions iterate supportable options and accept undefined (sequelize#18557)
  fix(core): respect the omitNull option of calls and models, fix query generator typings (sequelize#18565)
  meta(core): convert unit/model tests to TypeScript (sequelize#18564)
  meta(core): convert unit/instance tests to TypeScript (sequelize#18563)
  meta: update sequelize AUTHORS (sequelize#18549)
  feat(mssql): add useUnicodeStrings dialect option (sequelize#18548)
  meta: retry image pulls in the database start scripts (sequelize#18340)
  meta(core): follow-ups to the isModelStatic cache from sequelize#18234 (sequelize#18559)
  meta: update dependency uuid to v14 (sequelize#18544)
  ...

# Conflicts:
#	packages/core/src/abstract-dialect/query-generator.js
#	packages/core/src/abstract-dialect/query-interface-typescript.ts
#	packages/core/test/unit/model/bulk-create.test.js
#	packages/core/test/unit/sql/insert.test.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants