Fix inconsistent state when replacing an entire many to many relation

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • 2.1.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Previously there was a bug with many_to_many relationships that would improperly handing the unbinding of old relationships and not maintaining the new relationship when an entire many_to_many collection was replaced. Attempt at a coherent example below:

      person.preferences == [ pref1.existing ]

      person.preferences = [ pref2.new ]
      person.preferences == [ pref2.new ]
      pref1.people == [ person ] (wrong. it might have been right this long but a reload brought it back)
      pref2.people == [ person ]

      person.reload; pref1.reload; pref2.reload

      person.preferences == [ ] (wrong, should have pref2)
      pref1.people == [ person] (wrong, should no longer be related)
      pref2.people == [ person ]

      person.save; person.reload; pref1.reload; pref2.reload

      person.preferences == [ pref2 ]
      pref1.people == [ person] (wrong, should no longer be related)
      pref2.people == [ person ]

      Believe was the gist of it, but essentially it was getting into a half state between the old and new state.

      Thanks,
      Dave

              Assignee:
              Durran Jordan
              Reporter:
              Dave Krupinski
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: