# HG changeset patch # User someseven # Date 2021-10-08 05:21:21 # Node ID 94e6ef46ab2d4846f5765b941f78777382f66271 # Parent f8b202e4d30f302707b75e0b66a1129dca81e086 Fix transactions for objects fetched from the db (not created in this image) diff --git a/src/cache.lisp b/src/cache.lisp --- a/src/cache.lisp +++ b/src/cache.lisp @@ -12,7 +12,9 @@ (declare (ignore obj)) (maybe-lock (let ((*ignore-transaction* t)) - (do-cache (call-next-method))))) + (let ((obj (call-next-method))) + (setf (value-backup obj) nil) + (do-cache obj))))) (defmethod mito:insert-dao ((obj cached-dao)) (maybe-lock diff --git a/t/tests.lisp b/t/tests.lisp --- a/t/tests.lisp +++ b/t/tests.lisp @@ -77,4 +77,10 @@ (with-transaction () (setf (slot obj) 42) (rollback)) - (false (slot-boundp obj 'slot) "Transaction rollback failed to unbind a slot"))) + (false (slot-boundp obj 'slot) "Transaction rollback failed to unbind a slot") + (remhash (mito:object-id obj) (mito-transactions.dev::class-cache 'test-object))) + (let (obj) + (with-transaction () + (setf obj (find-dao 'test-object)) + (setf (slot obj) 2)) + (is = 2 (slot obj))))