r9209: read tinyint as integer for odbc, handle boolean reading/writing fields
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 3 May 2004 16:02:24 +0000 (16:02 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 3 May 2004 16:02:24 +0000 (16:02 +0000)
ChangeLog
TODO
db-odbc/odbc-dbi.lisp
debian/changelog
sql/objects.lisp
tests/test-fdml.lisp

index bc52ded8db0d4d3aa5a10d8795e9c2e3058e8259..70b20ca2500410737dfcd234a4ebd59beffe42db 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+3 May 2004 Kevin Rosenberg (kevin@rosenberg.net)
+       * Version 2.10.7
+       * db-odbc/odbc-dbi.lisp: Convert TINYINT to integers when
+       result-types is :auto
+       * sql/objects.lisp: Properly handled writing/reading Boolean
+       values from SQL database when retrieving objects.
+       * test/test-fdml.lisp: Add another test for boolean results
+       * test/utils.lisp: Fix incorrect declaration
+       
 2 May 2004 Marcus Pearce (m.t.pearce@city.ac.uk) 
        * Version 2.10.6
        * sql/generics.lisp: add generic function for SELECT. 
diff --git a/TODO b/TODO
index 6b6e144b186d86b2d2fd7a6e70afa39a60f381c0..b2a71d38b635f21b2b004a9a4843d188cb0061d1 100644 (file)
--- a/TODO
+++ b/TODO
@@ -13,7 +13,8 @@ TESTS TO ADD
   backends showing autogenerated primary key in different ways.
 * Test New universal and bigint types, add tests for other types such as duration and money
 * Large object testing
+* Test instance slot values when SELECT called for objects
+
 COMMONSQL SPEC
 
 * Missing: 
index 4a6107d93c9235f6f4eeb035cd0ac01d4e071d4d..0de8eddf4bd7bd58f27f845b664aeb6e9abbfea0 100644 (file)
@@ -454,10 +454,11 @@ This makes the functions db-execute-command and db-query thread safe."
              (#.odbc::$SQL_C_DOUBLE :double)
              (#.odbc::$SQL_C_FLOAT :float)
              (#.odbc::$SQL_C_SSHORT :short)
+             (#.odbc::$SQL_C_STINYINT :short)
              (#.odbc::$SQL_BIGINT :short)
              (t t))))
          (t
-         t)))))
+          t)))))
   query)
 
 (defun db-close-query (query &key drop-p)
index 4ecd29a7c9be250275774665a09726956d23f3c6..e3020e744d16e356470525c2a14508bc2650971d 100644 (file)
@@ -1,3 +1,9 @@
+cl-sql (2.10.7-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Mon,  3 May 2004 09:50:27 -0600
+
 cl-sql (2.10.6-1) unstable; urgency=low
 
   * New upstream
index a995c221fcf2b996e77de512bed0866cfb25cf38..0232917ff4662b7ca80ae62d79b75b86cfd4c08d 100644 (file)
@@ -430,9 +430,7 @@ superclass of the newly-defined View Class."
 (defmethod update-slot-with-null ((object standard-db-object)
                                  slotname
                                  slotdef)
-  (let ((st (slot-type slotdef))
-        (void-value (slot-value slotdef 'void-value)))
-    (setf (slot-value object slotname) void-value)))
+  (setf (slot-value object slotname) (slot-value slotdef 'void-value)))
 
 (defvar +no-slot-value+ '+no-slot-value+)
 
@@ -586,8 +584,11 @@ superclass of the newly-defined View Class."
     (prin1-to-string val)))
 
 (defmethod database-output-sql-as-type ((type (eql 'boolean)) val database)
-  (declare (ignore database))
-  (if val "t" "f"))
+  (case (database-underlying-type database)
+    (:mysql
+     (if val 1 0))
+    (t
+     (if val "t" "f"))))
 
 (defmethod database-output-sql-as-type ((type (eql 'string)) val database)
   (declare (ignore database))
@@ -658,8 +659,13 @@ superclass of the newly-defined View Class."
   (float (read-from-string val))) 
 
 (defmethod read-sql-value (val (type (eql 'boolean)) database)
-  (declare (ignore database))
-  (equal "t" val))
+  (case (database-underlying-type database)
+    (:mysql
+     (etypecase val
+       (string (if (string= "0" val) nil t))
+       (integer (if (zerop val) nil t))))
+    (t
+     (equal "t" val))))
 
 (defmethod read-sql-value (val (type (eql 'univeral-time)) database)
   (declare (ignore database))
index 39aac724057fcec3b61209ef9ef02725503cd52e..f7ee00504df2bddb8dba1c3f803a06c092a931be 100644 (file)
        (values results (mapcar #'string-downcase field-names)))
  ((1 "Lenin" "t"))
  ("emplid" "last_name" "married"))
+
 (deftest :fdml/select/14
      (floatp (car (clsql:select [height] :from [employee] :where [= [emplid] 1] 
                                :flatp t)))
   t)
 
+(deftest :fdml/select/15
+    (clsql:select [married] :from [employee] 
+     :where [= [emplid] 4]
+     :field-names nil)
+ (("f")))
 ;(deftest :fdml/select/11
 ;    (clsql:select [emplid] :from [employee]
 ;                :where [= [emplid] [any [select [companyid] :from [company]]]]