You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
I've hit a problem when using collection arithmetic. I'll mention up-front that it involves a 2 step association (i.e. :through => :an_intermediate_table).
I was getting what I felt were incorrect results and then, while debugging, I realised that forcing a collection to load data from the DB (by inspecting the collection) changed the results.
I've tried to shrink my code (below) down to the simplest possible example but it still looks bigger than I'd like. With the code as written, the output I get is:
require'dm-core'require'dm-migrations'classIssueincludeDataMapper::Resourceproperty:id,Serialbelongs_to:assigned_to,'User',:required=>falsebelongs_to:project,:required=>truehasn,:issue_commentsendclassIssueCommentincludeDataMapper::Resourceproperty:id,Serialbelongs_to:issue,:required=>truebelongs_to:user,:required=>trueendclassUserincludeDataMapper::Resourceproperty:id,Serialhasn,:assigned_issues,'Issue',:child_key=>[:assigned_to_id]hasn,:issue_commentshasn,:issues,:through=>:issue_commentsdefdiscussed_issues# Wanted "has n, :issues" to be "has n, :discussed_issues" but could# not figure out whether this was possible.issuesendendclassProjectincludeDataMapper::Resourceproperty:id,Serialhasn,:issuesendDataMapper.setup(:default,"sqlite3://#{Dir.pwd}/dm_test.db")DataMapper.finalizeDataMapper.auto_upgrade!ifUser.count == 0user=User.createproject=Project.createissues=[Issue.create(:project=>project,:assigned_to=>user),Issue.create(:project=>project),Issue.create(:project=>project)]comment=IssueComment.create(:issue=>issues[1],:user=>user)enduser=User.all.firstproject=Project.all.first# !!! Uncomment this line to get a different result !!!# user.discussed_issues.inspectassigned_issues=user.assigned_issues & Issue.all(:project=>project)discussed_issues=(user.discussed_issues & Issue.all(:project=>project)) - assigned_issuesother_issues=Issue.all(:project=>project) - (discussed_issues|assigned_issues)putsassigned_issues.inspectputsdiscussed_issues.inspectputsother_issues.inspect
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I've hit a problem when using collection arithmetic. I'll mention up-front that it involves a 2 step association (i.e. :through => :an_intermediate_table).
I was getting what I felt were incorrect results and then, while debugging, I realised that forcing a collection to load data from the DB (by inspecting the collection) changed the results.
I've tried to shrink my code (below) down to the simplest possible example but it still looks bigger than I'd like. With the code as written, the output I get is:
And after uncommenting the indicated line (which I expected to have no side-effects) the output I get is:
Neither output looks correct to me. I expected to see:
And here's the code:
The text was updated successfully, but these errors were encountered: