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

Baseclass becomes! subclass #14971

Merged
merged 1 commit into from
Jun 6, 2014
Merged

Baseclass becomes! subclass #14971

merged 1 commit into from
Jun 6, 2014

Conversation

ehtb
Copy link
Contributor

@ehtb ehtb commented May 4, 2014

Before this change, a record which changed its STI type, could not be found when updated.
Setting update_record to the base class, ensures the record can be found.

The idea was proposed by @matthewd in #14887

Closes #14785


@klass.connection.update(
um = base_class.unscoped.where(base_class.arel_table[base_class.primary_key].eq(id_was || id)).arel.compile_update(substitutes, base_class.primary_key)
Copy link
Member

Choose a reason for hiding this comment

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

when we assign the expression inside where to a variable? This line is very hard to read...

condition = base_class.arel_table[base_class.primary_key].eq(id_was || id)

senny added a commit that referenced this pull request May 7, 2014
This case prevents against regressions. The change was suggested in a recent
PR but the all our tests passed.
Before this change, a record which changed its STI type, could not be found when updated.
Setting update_record to the base class, ensures the record can be found.

Fixes #14785
Copy link
Member

Choose a reason for hiding this comment

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

nitpick, missing dot at the end.

@ehtb
Copy link
Contributor Author

ehtb commented May 24, 2014

@senny Any idea on the status of this? Thanks!

@senny
Copy link
Member

senny commented May 24, 2014

@VersionControl It's on my todo list. I will take a look in the upcoming days.

@senny senny merged commit 71c5d56 into rails:master Jun 6, 2014
senny added a commit that referenced this pull request Jun 6, 2014
@akshayrawat
Copy link

Is there a milestone set for this? Will this be a part of 4.1.5?

@rafaelfranca
Copy link
Member

By what I could see it will be only part of Rails 4.2.

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.

[AR] STI: Class becomes! subclass
5 participants