refactored database-output-sql-as-type in a similar fashion to
[clsql.git] / db-mysql / mysql-objects.lisp
index bbe52324fe2d0466849e51f49c741f5c02dac7ca..93a802f762ca3be7cefaa5229e0e894097373610 100644 (file)
@@ -6,8 +6,6 @@
 ;;;; Purpose:  CLSQL Object layer for MySQL
 ;;;; Created:  May 2004
 ;;;;
-;;;; $Id: mysql-sql.lisp 9403 2004-05-19 23:46:45Z kevin $
-;;;;
 ;;;; CLSQL users are granted the rights to distribute and use this software
 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
 (in-package #:clsql-mysql)
 
 (defmethod database-get-type-specifier ((type (eql 'wall-time)) args database
-                                       (db-type (eql :mysql)))
+                                        (db-type (eql :mysql)))
   (declare (ignore args database))
   "DATETIME")
 
-(defmethod database-output-sql-as-type ((type (eql 'boolean)) val database
-                                       (db-type (eql :mysql)))
-  (declare (ignore database))
-  (if val 1 0))
+(defmethod database-get-type-specifier ((type (eql 'smallint)) args database
+                                        (db-type (eql :mysql)))
+  (declare (ignore args database))
+  "SMALLINT")
+
+(defmethod database-get-type-specifier ((type (eql 'mediumint)) args database
+                                        (db-type (eql :mysql)))
+  (declare (ignore args database))
+  "MEDIUMINT")
+
+(defmethod database-get-type-specifier ((type (eql 'tinyint)) args database
+                                        (db-type (eql :mysql)))
+  (declare (ignore args database))
+  "TINYINT")
 
 (defmethod read-sql-value (val (type (eql 'boolean)) database
-                          (db-type (eql :mysql)))
-  (declare (ignore database)) 
+                           (db-type (eql :mysql)))
+  (declare (ignore database))
+  (etypecase val
+    (string (if (string= "0" val) nil t))
+    (integer (if (zerop val) nil t))))
+
+(defmethod read-sql-value (val (type (eql 'generalized-boolean)) database
+                           (db-type (eql :mysql)))
+  (declare (ignore database))
   (etypecase val
     (string (if (string= "0" val) nil t))
     (integer (if (zerop val) nil t))))