r9193: remove old :nulls-ok attribute. Add :void-value attribute.
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sat, 1 May 2004 22:00:53 +0000 (22:00 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sat, 1 May 2004 22:00:53 +0000 (22:00 +0000)
ChangeLog
doc/csql.xml
sql/generics.lisp
sql/metaclasses.lisp
sql/objects.lisp
tests/test-init.lisp

index dbf982459ee82867f87dce289a432e111b018e73..d20f186f7edead39a7dd5271b2d17e52c2f6ae29 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+1 May 2004 Kevin Rosenberg (kevin@rosenberg.net)
+       * Version 2.10.6-pre1
+       * sql/metaclasses.lisp: Add void-value slot
+       * doc/csql.xml: Update def-view-class documentation
+       * test/test-init.lisp: Change old :db-type to :db-kind.
+       Remove old :nulls-ok attributes.
+
 1 May 2004 Kevin Rosenberg (kevin@rosenberg.net)
        * Version 2.10.5: SQLite backend now passes all result-types tests
        * clsql-sqlite.asd: Depend on clsql-uffi system
index 47491ffe4fa44857334530ddd3e68054cfd01bd3..09ac4db272c5b5519f8a18e407698c75939db673 100644 (file)
@@ -247,16 +247,14 @@ mapped into a database).  They would be defined as follows:
 
   <listitem>
     <para>
-      <symbol>:db-type</symbol> - A string which will be used as the
+      <symbol>:column-</symbol> - A string which will be used as the
       type specifier for this slots column definition in the database.
       </para></listitem>
 
   <listitem>
     <para>
-      <symbol>:nulls-ok</symbol> - If &t;, all &sql; &null; values
-      retrieved from the database become nil; if &nil;, all &null;
-      values retrieved are converted by
-      <function>DATABASE-NULL-VALUE</function>. </para></listitem>
+      <symbol>:void-value</symbol> - The Lisp value to return if the
+      field is &null;. The default is &nil;.</para></listitem>
 
   <listitem>
     <para>
index d1b642aecf2202ebcf595302c926b082b5caa393..a7c8be1f5806901cdd4bfd9ce9744e6f1b245efb 100644 (file)
@@ -84,11 +84,6 @@ your application needs to take action when a View Class instance has
 been updated by (select ... :refresh t) then add an INSTANCE-REFRESH
 method specializing on your subclass of STANDARD-DB-OBJECT."))
 
-(defgeneric database-null-value (type)
-  (:documentation 
-   "Return an expression of type TYPE which SQL NULL values will be
-converted into."))
-
 (defgeneric update-slot-with-null (instance slotname slotdef)
   (:documentation "Called to update a slot when its column has a NULL
 value.  If nulls are allowed for the column, the slot's value will be
index b7b2e50b98f979927b5b6986ec4d760e5072905f..d6d92b85ce3595aef251d63779212c3fe69753b1 100644 (file)
@@ -56,8 +56,8 @@
 
 ;;; Lispworks 4.2 and before requires special processing of extra slot and class options
 
-(defvar +extra-slot-options+ '(:column :db-kind :db-reader :nulls-ok :db-constraints
-                                   :db-writer :db-type :db-info))
+(defvar +extra-slot-options+ '(:column :db-kind :db-reader :void-value :db-constraints
+                              :db-writer :db-info))
 (defvar +extra-class-options+ '(:base-table))
 
 (dolist (slot-option +extra-slot-options+)
@@ -287,13 +287,12 @@ column definition in the database.")
     :initform nil
     :documentation
     "A single constraint or list of constraints for this column")
-   (nulls-ok
-    :accessor view-class-slot-nulls-ok
-    :initarg :nulls-ok
+   (void-value
+    :accessor view-class-slot-void-value
+    :initarg :void-value
     :initform nil
     :documentation
-    "If t, all sql NULL values retrieved from the database become nil; if nil,
-all NULL values retrieved are converted by DATABASE-NULL-VALUE")
+    "Value to store is the SQL value is NULL. Default is NIL.")
    (db-info
     :accessor view-class-slot-db-info
     :initarg :db-info
@@ -443,8 +442,8 @@ which does type checking before storing a value in a slot."
              (when (slot-boundp sd 'db-type)
                (view-class-slot-db-type sd)))
        
-       (setf (slot-value slotd 'nulls-ok)
-             (view-class-slot-nulls-ok sd))
+       (setf (slot-value slotd 'void-value)
+             (view-class-slot-void-value sd))
        
        ;; :db-kind slot value defaults to :base (store slot value in
        ;; database)
index 0ea28e93c244ab4054404a392a8ca79bac80c916..f2d82e62e8fd2c7e737d4e43d636832e7d29cba2 100644 (file)
@@ -425,30 +425,12 @@ superclass of the newly-defined View Class."
       (get-slot-values-from-view instance (list slot-def) (car res)))))
 
 
-(defmethod database-null-value ((type t))
-  (cond
-    ((subtypep type 'string) nil)
-    ((subtypep type 'integer) nil)
-    ((subtypep type 'list) nil)
-    ((subtypep type 'boolean) nil)
-    ((eql type t) nil)
-    ((subtypep type 'symbol) nil)
-    ((subtypep type 'keyword) nil)
-    ((subtypep type 'wall-time) nil)
-    ((subtypep type 'duration) nil)
-    ((subtypep type 'money) nil)
-    (t
-     (error "Unable to handle null for type ~A" type))))
-
 (defmethod update-slot-with-null ((object standard-db-object)
                                  slotname
                                  slotdef)
   (let ((st (slot-type slotdef))
-        (allowed (slot-value slotdef 'nulls-ok)))
-    (if allowed
-        (setf (slot-value object slotname) nil)
-        (setf (slot-value object slotname)
-              (database-null-value st)))))
+        (void-value (slot-value slotdef 'void-value)))
+    (setf (slot-value object slotname) void-value)))
 
 (defvar +no-slot-value+ '+no-slot-value+)
 
index feee1d5ff328b9499ac31017536dfedc396bef28..d8eec640021ee61281e5b42515caa4bb0e4db717 100644 (file)
   ((extraterrestrial :initform nil :initarg :extraterrestrial)))
 
 (def-view-class person (thing)
-  ((height :db-kind :base :accessor height :type float :nulls-ok t
+  ((height :db-kind :base :accessor height :type float
            :initarg :height)
-   (married :db-kind :base :accessor married :type boolean :nulls-ok t
+   (married :db-kind :base :accessor married :type boolean
             :initarg :married)
-   (birthday :nulls-ok t :type clsql-base:wall-time :initarg :birthday)
+   (birthday :type clsql-base:wall-time :initarg :birthday)
    (hobby :db-kind :virtual :initarg :hobby :initform nil)))
   
 (def-view-class employee (person)
   ((emplid
     :db-kind :key
     :db-constraints :not-null
-    :nulls-ok nil
     :type integer
     :initarg :emplid)
    (groupid
     :db-kind :key
     :db-constraints :not-null
-    :nulls-ok nil
     :type integer
     :initarg :groupid)
    (first-name
@@ -65,7 +63,6 @@
    (email
     :accessor employee-email
     :type (string 100)
-    :nulls-ok t
     :initarg :email)
    (companyid
     :type integer)
@@ -77,8 +74,7 @@
                          :foreign-key companyid
                          :set nil))
    (managerid
-    :type integer
-    :nulls-ok t)
+    :type integer)
    (manager
     :accessor employee-manager
     :db-kind :join