Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5726

HABTM (Two-sided relationship) should use transactions to ensure data integrity

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Transactions
    • None

      Suppose I have:

      • Customer has_and_belongs_to_many reservations
      • Reservation has_and_belongs_to_many customers

      If I add a relation such as Customer.reservations << res, both the Customers and Reservations collections in my database will be updated. The updates to both collections should be wrapped in a single transaction, to ensure integrity of both collections.

      This ticket would only apply if I am using a server version which supports multi-collection transactions. I forget exactly but I think this was introduced in 4.2 for non-shards and 4.4 for shards.

      Transactions should not be used in the case of inverse_of: nil is used, because the relationship then becomes one-sided.

            Assignee:
            Unassigned Unassigned
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: