Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add isModelStatic, isSameInitialModel #14360

Merged
merged 4 commits into from
Apr 11, 2022
Merged

feat: add isModelStatic, isSameInitialModel #14360

merged 4 commits into from
Apr 11, 2022

Conversation

ephys
Copy link
Member

@ephys ephys commented Apr 11, 2022

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 For issues and PRs. For new features. Never breaking changes. label Apr 11, 2022
@ephys ephys self-assigned this Apr 11, 2022
Copy link
Member

@WikiRik WikiRik left a comment

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

src/utils/model-utils.ts Outdated Show resolved Hide resolved
src/utils/model-utils.ts Outdated Show resolved Hide resolved
test/unit/utils/model-utils.test.ts Outdated Show resolved Hide resolved
ephys and others added 2 commits April 11, 2022 12:52
Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com>
Copy link
Member

@WikiRik WikiRik left a comment

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

test/unit/utils/model-utils.test.ts Outdated Show resolved Hide resolved
Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com>
@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
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 <13023439+WikiRik@users.noreply.github.com>

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

Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com>

Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @v7 type: feature For issues and PRs. For new features. Never breaking changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants