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

fix: prevent public class fields from shadowing association values #16493

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

ephys
Copy link
Member

@ephys ephys commented Sep 12, 2023

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?
  • 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?
  • Does the name of your PR follow our conventions?

Description Of Change

Eager-loaded associations were suffering from the same issue as attributes: they get shadowed by public class fields declared on the model.

This adds a workaround. The actual solution would be to move everything from the constructor inside of the build method, so everything can be done after the class properties have been defined instead of before.

This will be possible to do in v8 when we ban using "new" on the model and require always using the build static method instead (deprecation warning & TODO are already present)

@ephys ephys added this pull request to the merge queue Sep 12, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 12, 2023
@WikiRik WikiRik added this pull request to the merge queue Sep 12, 2023
Merged via the queue into main with commit b66db0b Sep 12, 2023
52 checks passed
@WikiRik WikiRik deleted the ephys/fix-association-shadowing branch September 12, 2023 15:24
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