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 instantiation of inherited classes when querying #50553

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

Conversation

jvlara
Copy link

@jvlara jvlara commented Jan 3, 2024

Motivation / Background

This Pull Request has been created because #50499

Detail

Previously, querying from the base class resulted in an object of the inherited type, with 'ignored_columns' included in the 'attributes' method.

This behavior was inconsistent, as it did not occur when querying directly from the inherited class. This fix ensures consistent behavior in the attributes between the two ways of instantiate inherited classes during querying.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated 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.

@jvlara jvlara changed the title Fix instantiation of inherited classes when quering Fix instantiation of inherited classes when querying Jan 3, 2024
Copy link
Member

@Edouard-chin Edouard-chin left a comment

Choose a reason for hiding this comment

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

A couple of suggestions. Thank you!

activerecord/lib/active_record/persistence.rb Outdated Show resolved Hide resolved
activerecord/test/cases/inheritance_test.rb Outdated Show resolved Hide resolved
activerecord/test/cases/inheritance_test.rb Outdated Show resolved Hide resolved
@jvlara jvlara force-pushed the bugfix/fix-intantiation-of-attributes-on-inherited-classes-when-quering branch from 11a5219 to c8ad876 Compare January 5, 2024 15:40
@Edouard-chin
Copy link
Member

Thanks 👍 . Someone from the core team will have a look and merge when they get a chance.

Previously, querying from the base class resulted in an object of the inherited type,
with 'ignored_columns' included in the 'attributes' method.
This behavior was inconsistent, as it did not occur when querying directly from the inherited class.
This fix ensures consistent behavior in class instantiation during queries.
@jvlara jvlara force-pushed the bugfix/fix-intantiation-of-attributes-on-inherited-classes-when-quering branch from c8ad876 to 8c4764f Compare January 11, 2024 14:43
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.

None yet

3 participants