r9576: Add generalized-boolean
[clsql.git] / sql / oodml.lisp
index 399519cfa0bef8d9544cf3a9b458e4c90513deb4..329444363b6ed723dab505ae92e3ae5eaebd9441 100644 (file)
       (format nil "FLOAT(~A)" (car args))
       "FLOAT"))
 
+(deftype generalized-boolean () 
+  "A type which outputs a SQL boolean value, though any lisp type can be stored in the slot."
+  t)
+
 (defmethod database-get-type-specifier ((type (eql 'boolean)) args database db-type)
   (declare (ignore args database db-type))
   "BOOL")
 
+(defmethod database-get-type-specifier ((type (eql 'generalized-boolean)) args database db-type)
+  (declare (ignore args database db-type))
+  "BOOL")
+
 (defmethod database-get-type-specifier ((type (eql 'number)) args database db-type)
   (declare (ignore database db-type))
   (cond
   (declare (ignore database db-type))
   (if val "t" "f"))
 
+(defmethod database-output-sql-as-type ((type (eql 'generalized-boolean)) val database db-type)
+  (declare (ignore database db-type))
+  (if val "t" "f"))
+
 (defmethod database-output-sql-as-type ((type (eql 'string)) val database db-type)
   (declare (ignore database db-type))
   val)
   (declare (ignore database db-type))
   (equal "t" val))
 
+(defmethod read-sql-value (val (type (eql 'generalized-boolean)) database db-type)
+  (declare (ignore database db-type))
+  (equal "t" val))
+
 (defmethod read-sql-value (val (type (eql 'number)) database db-type)
   (declare (ignore database db-type))
   (etypecase val