- (view-class-slot-definition-mixin
- ;; Use the specified :column argument if it is supplied, otherwise
- ;; the column slot is filled in with the slot-name, but transformed
- ;; to be sql safe, - to _ and such.
- (setf (slot-value esd 'column)
- (column-name-from-arg
- (if (slot-boundp dsd 'column)
- (delistify-dsd (view-class-slot-column dsd))
- (column-name-from-arg
- (sql-escape (slot-definition-name dsd))))))
-
- (setf (slot-value esd 'db-type)
- (when (slot-boundp dsd 'db-type)
- (delistify-dsd
- (view-class-slot-db-type dsd))))
-
- (setf (slot-value esd 'void-value)
- (delistify-dsd
- (view-class-slot-void-value dsd)))
-
- ;; :db-kind slot value defaults to :base (store slot value in
- ;; database)
-
- (setf (slot-value esd 'db-kind)
- (if (slot-boundp dsd 'db-kind)
- (delistify-dsd (view-class-slot-db-kind dsd))
- :base))
-
- (setf (slot-value esd 'db-writer)
- (when (slot-boundp dsd 'db-writer)
- (delistify-dsd (view-class-slot-db-writer dsd))))
- (setf (slot-value esd 'db-constraints)
- (when (slot-boundp dsd 'db-constraints)
- (delistify-dsd (view-class-slot-db-constraints dsd))))
-
- ;; I wonder if this slot option and the previous could be merged,
- ;; so that :base and :key remain keyword options, but :db-kind
- ;; :join becomes :db-kind (:join <db info .... >)?
-
- (setf (slot-value esd 'db-info)
- (when (slot-boundp dsd 'db-info)
- (let ((dsd-info (view-class-slot-db-info dsd)))
- (cond
- ((atom dsd-info)
- dsd-info)
- ((and (listp dsd-info) (> (length dsd-info) 1)
- (atom (car dsd-info)))
- (parse-db-info dsd-info))
- ((and (listp dsd-info) (= 1 (length dsd-info))
- (listp (car dsd-info)))
- (parse-db-info (car dsd-info)))))))
-
- (setf (specified-type esd)
- (delistify-dsd (specified-type dsd)))
-
- )
- ;; all other slots
- (t
- (let ((type-predicate #+openmcl (slot-value esd 'ccl::type-predicate)))
- #-openmcl (declare (ignore type-predicate))
- (change-class esd 'view-class-effective-slot-definition
- #+allegro :name
- #+allegro (slot-definition-name dsd))
- #+openmcl (setf (slot-value esd 'ccl::type-predicate)
- type-predicate))
-
- (setf (slot-value esd 'column)
- (column-name-from-arg
- (sql-escape (slot-definition-name dsd))))
-
- (setf (slot-value esd 'db-info) nil)
- (setf (slot-value esd 'db-kind) :virtual)
- (setf (specified-type esd) (slot-definition-type dsd)))
- )
+ (view-class-slot-definition-mixin
+ ;; Use the specified :column argument if it is supplied, otherwise
+ ;; the column slot is filled in with the slot-name, but transformed
+ ;; to be sql safe, - to _ and such.
+ (setf (slot-value esd 'column)
+ (column-name-from-arg
+ (if (slot-boundp dsd 'column)
+ (delistify-dsd (view-class-slot-column dsd))
+ (column-name-from-arg
+ (sql-escape (slot-definition-name dsd))))))
+
+ (setf (slot-value esd 'db-type)
+ (when (slot-boundp dsd 'db-type)
+ (delistify-dsd
+ (view-class-slot-db-type dsd))))
+
+ (setf (slot-value esd 'void-value)
+ (delistify-dsd
+ (view-class-slot-void-value dsd)))
+
+ ;; :db-kind slot value defaults to :base (store slot value in
+ ;; database)
+
+ (setf (slot-value esd 'db-kind)
+ (if (slot-boundp dsd 'db-kind)
+ (delistify-dsd (view-class-slot-db-kind dsd))
+ :base))
+
+ (setf (slot-value esd 'db-reader)
+ (when (slot-boundp dsd 'db-reader)
+ (delistify-dsd (view-class-slot-db-reader dsd))))
+ (setf (slot-value esd 'db-writer)
+ (when (slot-boundp dsd 'db-writer)
+ (delistify-dsd (view-class-slot-db-writer dsd))))
+ (setf (slot-value esd 'db-constraints)
+ (when (slot-boundp dsd 'db-constraints)
+ (delistify-dsd (view-class-slot-db-constraints dsd))))
+
+ ;; I wonder if this slot option and the previous could be merged,
+ ;; so that :base and :key remain keyword options, but :db-kind
+ ;; :join becomes :db-kind (:join <db info .... >)?
+
+ (setf (slot-value esd 'db-info)
+ (when (slot-boundp dsd 'db-info)
+ (let ((dsd-info (view-class-slot-db-info dsd)))
+ (cond
+ ((atom dsd-info)
+ dsd-info)
+ ((and (listp dsd-info) (> (length dsd-info) 1)
+ (atom (car dsd-info)))
+ (parse-db-info dsd-info))
+ ((and (listp dsd-info) (= 1 (length dsd-info))
+ (listp (car dsd-info)))
+ (parse-db-info (car dsd-info)))))))
+
+ (setf (specified-type esd)
+ (delistify-dsd (specified-type dsd)))
+ ;; The type-check-function is computed at defclass expansion,
+ ;; which is too early for the CLSQL type conversion to take
+ ;; place. This gets rid of it. It's ugly but it's better
+ ;; than nothing -wcp10/4/10.
+ #+sbcl (setf (slot-value esd 'sb-pcl::%type-check-function) nil)
+
+ )
+ ;; all other slots
+ (t
+ (unless (typep esd 'view-class-effective-slot-definition)
+ (warn "Non view-class-direct-slot object with non-view-class-effective-slot-definition in compute-effective-slot-definition")
+
+ (let ((type-predicate #+openmcl (slot-value esd 'ccl::type-predicate)))
+ #-openmcl (declare (ignore type-predicate))
+ #-(or clisp sbcl) (change-class esd 'view-class-effective-slot-definition
+ #+allegro :name
+ #+allegro (slot-definition-name dsd))
+ #+openmcl (setf (slot-value esd 'ccl::type-predicate)
+ type-predicate)))
+
+ (setf (slot-value esd 'column)
+ (column-name-from-arg
+ (sql-escape (slot-definition-name dsd))))
+
+ (setf (slot-value esd 'db-info) nil)
+ (setf (slot-value esd 'db-kind) :virtual)
+ (setf (specified-type esd) (slot-definition-type dsd)))
+ )