I tried multiple ways to get the with-column-writers macro in the
repository to work and could not. I believe that the loop should read
:in rather than :on as follows:
(defmacro with-column-writers ((&rest defs) &body body)
`(let ((*custom-column-writers* (append (list ,@(loop :for (field
writer) :in defs
:collect
`(cons (to-sql-name ,field) ,writer)))
*custom-column-writers*)))
,@body))
With that in place, the following code works correctly:
(defclass foo ()
((id :col-type int :initform :id :accessor foo-id)
(stuff :initform :stuff :accessor foo-stuff))
(:metaclass postmodern:dao-class)
(:keys id))
(setf foo
(postmodern:with-column-writers
((:id #'(lambda (inst val)
(setf (foo-id inst) val)
(setf (foo-stuff inst)
(format nil "My Value: ~A" val)))))
(postmodern:get-dao 'foo 1)))