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 #51720] Infer association klass as top level if model has same demodularized name #51721

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joshuay03
Copy link
Contributor

@joshuay03 joshuay03 commented May 3, 2024

Motivation / Background

Fixes #51720

Detail

Updates AbstractReflection#klass and its only subclass override MacroReflection#klass to infer the association class as a top level class if the name of the model without module name-spacing is the same. The current inferrence is due to this logic resolving the name in the current module first, which doesn't make sense in this specific case as it will always resolve to the model itself.

Additional information

None.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@joshuay03 joshuay03 force-pushed the fix-same-association-name-as-demodularized-model-name branch from 2ce81b0 to fc52884 Compare May 3, 2024 03:31
Admin::User
)

assert_equal User, reflection.klass
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before patch:

Screenshot 2024-05-03 at 1 10 59 PM

@joshuay03 joshuay03 force-pushed the fix-same-association-name-as-demodularized-model-name branch from fc52884 to b27ccdb Compare May 3, 2024 03:44
Admin::User
)

assert_equal Nested::User, reflection.klass
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this to make sure we don't regress on this case.

@joshuay03 joshuay03 force-pushed the fix-same-association-name-as-demodularized-model-name branch from b27ccdb to fabbe59 Compare May 3, 2024 03:56
@joshuay03 joshuay03 force-pushed the fix-same-association-name-as-demodularized-model-name branch from fabbe59 to 45b45e0 Compare May 3, 2024 05:49
@joshuay03 joshuay03 force-pushed the fix-same-association-name-as-demodularized-model-name branch from 45b45e0 to f48afa8 Compare May 5, 2024 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Association with the same name as the demodularized model name is incorrectly inferred
1 participant