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

Squeel query returns outdated result #443

Closed
dariusf opened this issue Jul 23, 2015 · 7 comments · Fixed by #4065
Closed

Squeel query returns outdated result #443

dariusf opened this issue Jul 23, 2015 · 7 comments · Fixed by #4065

Comments

@dariusf
Copy link
Contributor

dariusf commented Jul 23, 2015

Achievement condition validations cause a bug in squeel 1.2.3 where the ActiveRecord object returned is not up to date. The workaround implemented in #425 should be reverted when this is fixed.

def achievement_conditions(id)
  Course::Condition::Achievement.
    joins { condition.conditional(Course::Achievement) }.
    where{condition.conditional.id == id}
end

# Here achievement 2 has achievement 1 as a condition

achievement_conditions(2).first
=> #<Course::Condition::Achievement id: 1, achievement_id: 1>

achievement_conditions(2).first.achievement
=> #<Course::Achievement id: 2, course_id: 1, title: "two", description: "", weight: 10, published: false, creator_id: 1, updater_id: 1, created_at: "2015-07-23 03:35:19", updated_at: "2015-07-23 03:35:19">

achievement_conditions(2).first.achievement_id
=> 1

achievement_conditions(2).first.achievement.id
=> 2

c = achievement_conditions(2).first
=> #<Course::Condition::Achievement id: 1, achievement_id: 1>

c.achievement
=> #<Course::Achievement id: 2, course_id: 1, title: "two", description: "", weight: 10, published: false, creator_id: 1, updater_id: 1, created_at: "2015-07-23 03:35:19", updated_at: "2015-07-23 03:35:19">

# Result is correct after reload

c.reload
=> #<Course::Achievement id: 1, course_id: 1, title: "one", description: "", weight: 10, published: false, creator_id: 1, updater_id: 1, created_at: "2015-07-23 03:35:11", updated_at: "2015-07-23 03:35:11">
@lowjoel
Copy link
Member

lowjoel commented Jul 23, 2015

Maybe you can create a minimal repro and create in the Squeel issue tracker instead.

@lowjoel
Copy link
Member

lowjoel commented Jul 31, 2016

@allenwq has this been fixed?

@allenwq
Copy link
Member

allenwq commented Jul 31, 2016

We have a TODO in our codebase already, and it's 1 year long so I cleaned this up.

@lowjoel
Copy link
Member

lowjoel commented Aug 1, 2016

I'd keep it open because it has not been fixed in Squeel. This would affect other parts soon enough.

@allenwq
Copy link
Member

allenwq commented Aug 1, 2016

Sure.

@allenwq allenwq reopened this Aug 1, 2016
@kxmbrian
Copy link
Contributor

kxmbrian commented Jan 3, 2018

Closing this because squeel is no longer used after #2283.

@kxmbrian kxmbrian closed this as completed Jan 3, 2018
@kxmbrian
Copy link
Contributor

kxmbrian commented Jan 3, 2018

Some files related to #425 not yet cleaned up, e.g.:

  • app/models/course/condition/achievement.rb
  • app/models/course/condition/assessment.rb
  • spec/models/course/condition/assessment_spec.rb
  • spec/models/course/condition/achievement_spec.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants