2010/11/17

CLSQL で MySQL の auto_increment と text を使う

(deftype text ()
'string)

(defmethod clsql-sys:database-get-type-specifier ((type (eql 'text)) args database db-type)
(declare (ignore args database db-type))
"TEXT")

(defun print-slots (object &optional (stream t))
(print-unreadable-object (object stream :type t :identity t)
(format stream "~{~{~a: ~a~}~^ ~}"
(collect (#M(^ (list _ (slot-value object _)))
(choose-if (complement (^ eq 'clsql-sys::view-database _))
(c2mop:slot-definition-name
(scan (c2mop:class-slots (class-of object))))))))))

(def-view-class entry ()
((id :initarg :id :accessor it :type integer
:db-kind :key
:db-constraints :auto-increment)
(title :initarg :title :accessor title :type string)
(content :initarg :content :accessor content :type text)
(created-at :initarg :created-at :initform (get-time)
:accessor created-at
:type wall-time)))

0 件のコメント: