Support :autoincrement for Postgres on table creation by rebuilding what Postgres...
[clsql.git] / sql / metaclasses.lisp
index 72a3388db78d93823cff55b1bb65376f21392e92..1ae635a9eb9ea3679192c83ed51cddebc07b0999 100644 (file)
                                           base-table))
                                  (class-name class)))))
 
+(defgeneric ordered-class-direct-slots (class))
 (defmethod ordered-class-direct-slots ((self standard-db-class))
   (let ((direct-slot-names
          (mapcar #'slot-definition-name (class-direct-slots self)))
@@ -313,7 +314,13 @@ column definition in the database.")
     :accessor specified-type
     :initarg specified-type
     :initform nil
-    :documentation "Internal slot storing the :type specified by user.")))
+    :documentation "Internal slot storing the :type specified by user.")
+   (autoincrement-sequence
+    :accessor view-class-slot-autoincrement-sequence
+    :initarg :autoincrement-sequence
+    :initform nil
+    :documentation "A string naming the (possibly automatically generated) sequence 
+for a slot with an :auto-increment constraint.")))
 
 (defparameter *db-info-lambda-list*
   '(&key join-class
@@ -424,7 +431,7 @@ implementations."
             specified-type))))
     (if (and type (not (member :not-null (listify db-constraints))))
         `(or null ,type)
-      type)))
+        (or type t))))
 
 ;; Compute the slot definition for slots in a view-class.  Figures out
 ;; what kind of database value (if any) is stored there, generates and
@@ -452,8 +459,10 @@ implementations."
           (slot-definition-name obj)))
   (apply #'call-next-method obj
          'specified-type type
-         :type (compute-lisp-type-from-specified-type
-                type db-constraints)
+         :type (if (and (eql db-kind :virtual) (null type))
+                   t
+                   (compute-lisp-type-from-specified-type
+                    type db-constraints))
          initargs))
 
 (defmethod compute-effective-slot-definition ((class standard-db-class)