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

Fixed issue with transitions using STI #503

Merged

Conversation

pedro-pedrosa
Copy link
Contributor

Prior to 7.2.0 the code to unset the most_recent column of old transitions when a new transition was created relied on transitions_for_parent, which would build the correct query in the case that the transition class was using single table inheritance.

However, after #399, the code no longer uses the parent association to create the query and the current custom query lacks this functionality that existed prior to 7.2.0.

This PR addresses this issue by adding an AND clause to the query to filter by transition type if the transition class contains an inheritance column.

Copy link
Contributor

@Tabby Tabby left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for fixing this!

@artyrcheek
Copy link

Would love this to get merged, currently being bitten by this. Thanks @pedro-pedrosa

Updating the `most_recent` column of all transitions of a model
was not taking into account multiple state machines on the same
model whose transitions implemented STI

Add an AND clause to the query to filter by transition type
if the transition class contains an inheritance column
@Tabby Tabby force-pushed the bugfix/active-record-adapter/sti branch from 46432e6 to 66629e3 Compare April 6, 2023 09:36
@Tabby Tabby merged commit 2a9d8ac into gocardless:master Apr 6, 2023
56 checks passed
@pedro-pedrosa pedro-pedrosa deleted the bugfix/active-record-adapter/sti branch July 7, 2023 10:16
dylan-hoefsloot pushed a commit to dylan-hoefsloot/statesman that referenced this pull request Jan 11, 2024
Prior to 7.2.0 the code to unset the most_recent column of old transitions when a new transition was created relied on transitions_for_parent, which would build the correct query in the case that the transition class was using single table inheritance.

However, after gocardless#399, the code no longer uses the parent association to create the query and the current custom query lacks this functionality that existed prior to 7.2.0.

This PR addresses this issue by adding an AND clause to the query to filter by transition type if the transition class contains an inheritance column.
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

3 participants