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 compare target prototype equal to inheritance property #1019

Merged
merged 1 commit into from Sep 27, 2021
Merged

feat(): add compare target prototype equal to inheritance property #1019

merged 1 commit into from Sep 27, 2021

Conversation

namhhitvn
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #1018

What is the new behavior?

The Schema can inheritance property another class

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

a.target.prototype ?
isTargetEqual({ target: (a.target as any).__proto__ }, b) :
false
);
Copy link
Member

Choose a reason for hiding this comment

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

We might need to loop through prototypes here (to fully support the inheritance). The current solution looks like a workaround that won't work for longer inheritance chains.

Copy link
Author

Choose a reason for hiding this comment

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

This works for longer inheritance chains because this function is applied to filter to get metadata properties of schemas.

Function reference:
https://github.com/nestjs/mongoose/blob/HEAD/lib/storages/type-metadata.storage.ts#L23-L29

@kamilmysliwiec
Copy link
Member

LGTM

@kamilmysliwiec kamilmysliwiec merged commit cc4b5a2 into nestjs:master Sep 27, 2021
@namhhitvn namhhitvn deleted the feature/schema-multiple-inheritances branch September 27, 2021 08:36
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.

None yet

2 participants