From aeca9641c36caae6853536a11c2ad5990a00cc66 Mon Sep 17 00:00:00 2001
From: Russ Tyndall <russ@acceleration.net>
Date: Fri, 26 Jul 2013 12:32:05 -0400
Subject: [PATCH] reset dirty slots after initialization, because they are not
 really dirty if we are setting their initial value

---
 dirty.lisp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/dirty.lisp b/dirty.lisp
index 8102321..8a19421 100644
--- a/dirty.lisp
+++ b/dirty.lisp
@@ -7,6 +7,11 @@
    (old-value :accessor old-value :initarg :old-value :initform nil)
    (new-value :accessor new-value :initarg :new-value :initform nil)))
 
+(defmethod print-object ((o dirty-slot) s)
+  "Print the auto-print-items for this instance."
+  (print-unreadable-object (o s :type t :identity t)
+    (ignore-errors (format s "~A" (slot-name o)))))
+
 (defun make-dirty-slot (name old new)
   (make-instance 'dirty-slot :slot-name name :old-value old :new-value new))
 
@@ -17,6 +22,14 @@
                :db-kind :virtual))
   (:metaclass clsql-sys::standard-db-class))
 
+(defmethod initialize-instance :after ((o dirty-db-slots-mixin)
+                                       &key &allow-other-keys)
+  ;; lets reset any changes caused by initialization
+  ;; Not sure if this is correct, but other mixins are setting
+  ;; values during init, which are not particularly dirty
+  ;; (ie they havent changed, just got set)
+  (reset-dirty o))
+
 (defun find-dirty-test ( o slot-name )
   (or
    (iter (for (slot-names . test) in (dirty-test o))