From f69c5bfba59d54628f9a08b83413ec3df3c92432 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 3 May 2004 16:02:24 +0000 Subject: [PATCH] r9209: read tinyint as integer for odbc, handle boolean reading/writing fields --- ChangeLog | 9 +++++++++ TODO | 3 ++- db-odbc/odbc-dbi.lisp | 3 ++- debian/changelog | 6 ++++++ sql/objects.lisp | 20 +++++++++++++------- tests/test-fdml.lisp | 8 +++++++- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc52ded..70b20ca 100644 --- 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 6b6e144..b2a71d3 100644 --- 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: diff --git a/db-odbc/odbc-dbi.lisp b/db-odbc/odbc-dbi.lisp index 4a6107d..0de8edd 100644 --- a/db-odbc/odbc-dbi.lisp +++ b/db-odbc/odbc-dbi.lisp @@ -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) diff --git a/debian/changelog b/debian/changelog index 4ecd29a..e3020e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cl-sql (2.10.7-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Mon, 3 May 2004 09:50:27 -0600 + cl-sql (2.10.6-1) unstable; urgency=low * New upstream diff --git a/sql/objects.lisp b/sql/objects.lisp index a995c22..0232917 100644 --- a/sql/objects.lisp +++ b/sql/objects.lisp @@ -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)) diff --git a/tests/test-fdml.lisp b/tests/test-fdml.lisp index 39aac72..f7ee005 100644 --- a/tests/test-fdml.lisp +++ b/tests/test-fdml.lisp @@ -281,12 +281,18 @@ (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]]]] -- 2.34.1