Skip to content

feat: add isModelStatic, isSameInitialModel - #14360

Merged
WikiRik merged 4 commits into
mainfrom
ephys/model-utils
Apr 11, 2022
Merged

WikiRik merged 4 commits into
mainfrom
ephys/model-utils

Conversation

@ephys

@ephys ephys commented Apr 11, 2022

Copy link
Copy Markdown
Member

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • Does yarn test or yarn test-DIALECT pass with this change (including linting)?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description Of Change

This PR adds two new utility methods:

  • isModelStatic: returns true if the value is a subclass (not instance) of model
  • isSameInitialModel: returns true if two models are variants of the same model

Both were initially created for #14280, but this PR also refactors the existing codebase to use them where it makes sense

@ephys ephys added the type: feature DEPRECATED: replace with the "feature" issue type label Apr 11, 2022
@ephys ephys self-assigned this Apr 11, 2022
@ephys ephys mentioned this pull request Apr 11, 2022
8 of 15 tasks

@WikiRik WikiRik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice utility function to add. Do have a few remarks

Comment thread src/utils/model-utils.ts Resolved
Comment thread src/utils/model-utils.ts Resolved
Comment thread test/unit/utils/model-utils.test.ts Resolved

@WikiRik WikiRik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final remark and then we're good to go

Comment thread test/unit/utils/model-utils.test.ts Resolved
@WikiRik
WikiRik merged commit 07b95dd into main Apr 11, 2022
@WikiRik
WikiRik deleted the ephys/model-utils branch April 11, 2022 11:30
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 7.0.0-alpha.11 🎉

The release is available on:

Your semantic-release bot 📦🚀

vanthome pushed a commit to vanthome/sequelize that referenced this pull request Jun 12, 2022
* feat: add isModelStatic, isSameInitialModel

* docs: rework isSameInitialModel docs

* Update test/unit/utils/model-utils.test.ts

Co-authored-by: Rik Smale <[email protected]>

* Update test/unit/utils/model-utils.test.ts

Co-authored-by: Rik Smale <[email protected]>

Co-authored-by: Rik Smale <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released on @v7 type: feature DEPRECATED: replace with the "feature" issue type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants