+
+(defmethod database-identifier ( (name standard-db-class)
+ &optional database find-class-p)
+ "the majority of this function is in expressions.lisp
+ this is here to make loading be less painful (try-recompiles) in SBCL"
+ (declare (ignore find-class-p))
+ (database-identifier (view-table name) database))
+
+(defmethod database-identifier ((name view-class-slot-definition-mixin)
+ &optional database find-class-p)
+ (declare (ignore find-class-p))
+ (database-identifier
+ (if (slot-boundp name 'column)
+ (delistify-dsd (view-class-slot-column name))
+ (slot-definition-name name))
+ database))
+
+(defun find-standard-db-class (name &aux cls)
+ (and (setf cls (ignore-errors (find-class name)))
+ (typep cls 'standard-db-class)
+ cls))
+
+(defun slots-for-possibly-normalized-class (class)
+ "Get the slots for this class, if normalized this is only the direct slots
+ otherwiese its all the slots"
+ (if (normalizedp class)
+ (ordered-class-direct-slots class)
+ (ordered-class-slots class)))
+
+
+(defun key-slot-p (slot-def)
+ "takes a slot def and returns whether or not it is a key"
+ (eql :key (view-class-slot-db-kind slot-def)))
+
+(defun join-slot-p (slot-def)
+ "takes a slot def and returns whether or not it is a join slot"
+ (eql :join (view-class-slot-db-kind slot-def)))
+
+(defun join-slot-info-value (slot-def key)
+ "Get the join-slot db-info value associated with a key"
+ (when (join-slot-p slot-def)
+ (let ((dbi (view-class-slot-db-info slot-def)))
+ (when dbi (gethash key dbi)))))
+
+(defun join-slot-retrieval-method (slot-def)
+ "if this is a join slot return the retrieval param in the db-info"
+ (join-slot-info-value slot-def :retrieval))
+
+(defun join-slot-class-name (slot-def)
+ "get the join class name for a given join slot"
+ (join-slot-info-value slot-def :join-class))
+
+(defun join-slot-class (slot-def)
+ "Get the join class for a given join slot"
+ (let ((c (join-slot-class-name slot-def)))
+ (when c (find-class c))))
+
+(defun key-or-base-slot-p (slot-def)
+ "takes a slot def and returns whether or not it is a key"
+ (member (view-class-slot-db-kind slot-def) '(:key :base)))
+
+(defun direct-normalized-slot-p (class slot-name)
+ "Is this a normalized class and if so is the slot one of our direct slots?"
+ (setf slot-name (to-slot-name slot-name))
+ (and (typep class 'standard-db-class)
+ (normalizedp class)
+ (member slot-name (ordered-class-direct-slots class)
+ :key #'slot-definition-name)))
+
+(defun not-direct-normalized-slot-p (class slot-name)
+ "Is this a normalized class and if so is the slot not one of our direct slots?"
+ (setf slot-name (to-slot-name slot-name))
+ (and (typep class 'standard-db-class)
+ (normalizedp class)
+ (not (member slot-name (ordered-class-direct-slots class)
+ :key #'slot-definition-name))))
+
+(defun slot-has-default-p (slot)
+ "returns nil if the slot does not have a default constraint"
+ (let* ((constraints
+ (when (typep slot '(or view-class-direct-slot-definition
+ view-class-effective-slot-definition))
+ (listify (view-class-slot-db-constraints slot)))))
+ (member :default constraints)))
+