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

Enum scopes and STI conditions don't get along #23013

Closed
claudiob opened this issue Jan 11, 2016 · 5 comments
Closed

Enum scopes and STI conditions don't get along #23013

claudiob opened this issue Jan 11, 2016 · 5 comments

Comments

@claudiob
Copy link
Member

This is a regression on master, from 4.2.

https://gist.github.com/claudiob/ae3452eaa3cf6307453a

  • I have an Activity class with a status enum which can be pending, failed or successful
  • Activity has two subclasses: Snapshot and Adjustment
  • First I create a successful Adjustment
  • Then I create a successful Snapshot
  • Then I query for the first successful Snapshot, and I expect to get a Snapshot object, but instead I get an Adjustment object

I haven't tracked down the case yet but I believe it's related to #22426.
In fact, the SQL that runs for Snapshot.successful.first is different:

# Snapshot.successful.first # in Rails 4.2
SELECT  "activities".* FROM "activities" WHERE "activities"."type" IN ('Snapshot') AND "activities"."status" = ?  ORDER BY "activities"."id" ASC LIMIT 1  [["status", 2]]

# Snapshot.successful.first # in Rails 5.0.0.beta1
SELECT  "activities".* FROM "activities" WHERE "activities"."status" = ? ORDER BY "activities"."id" ASC LIMIT ?  [["status", 2], ["LIMIT", 1]]

Applying the version of rails/rails patched by #22426 does not seem to fix the issue.

@maclover7
Copy link
Contributor

Working on a bisect for this.

@maclover7
Copy link
Contributor

Getting 5e0b555 as the bad commit from my bisect.

@claudiob
Copy link
Member Author

Thanks @maclover7 ! @sgrif does that sound familiar?

@maclover7
Copy link
Contributor

Will check whether #23004 fixed this.

@claudiob
Copy link
Member Author

It doesn't, I already checked.

@sgrif sgrif closed this as completed in b7cce1c Jan 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants