From 8535462c3fdef182cd226770e6e07160f380acac Mon Sep 17 00:00:00 2001 From: Russ Tyndall Date: Thu, 9 Jun 2011 14:27:53 -0400 Subject: [PATCH] made odbc read (from c) decimals and numerics as doubles instead of strings TODO: Read these numbers in as rationals instead of floats --- db-odbc/odbc-api.lisp | 9 ++++++--- db-odbc/odbc-dbi.lisp | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/db-odbc/odbc-api.lisp b/db-odbc/odbc-api.lisp index 79b38f2..076a59f 100644 --- a/db-odbc/odbc-api.lisp +++ b/db-odbc/odbc-api.lisp @@ -673,9 +673,12 @@ as possible second argument) to the desired representation of date/time/timestam (#.$SQL_SMALLINT (get-cast-short data-ptr)) ;; ?? (#.$SQL_INTEGER (get-cast-int data-ptr)) (#.$SQL_BIGINT (get-cast-big data-ptr)) - (#.$SQL_DECIMAL - (let ((*read-base* 10)) - (read-from-string (get-cast-foreign-string data-ptr)))) + ;; TODO: Change this to read in rationals instead of doubles + ((#.$SQL_DECIMAL #.$SQL_NUMERIC) + (let* ((*read-base* 10) + (*read-default-float-format* 'double-float) + (str (get-cast-foreign-string data-ptr))) + (read-from-string str))) (#.$SQL_BIT (get-cast-byte data-ptr)) (t (case c-type diff --git a/db-odbc/odbc-dbi.lisp b/db-odbc/odbc-dbi.lisp index 5c57c2e..3abce4a 100644 --- a/db-odbc/odbc-dbi.lisp +++ b/db-odbc/odbc-dbi.lisp @@ -465,6 +465,11 @@ This makes the functions db-execute-command and db-query thread safe." (#.odbc::$SQL_C_STINYINT :short) (#.odbc::$SQL_C_SBIGINT #.odbc::$ODBC-BIG-TYPE) (#.odbc::$SQL_C_TYPE_TIMESTAMP :time) + (#.odbc::$SQL_C_CHAR ;; TODO: Read this as rational instead of double + (or (case (aref column-sql-types i) + (#.odbc::$SQL_NUMERIC :double)) + T)) + (t t))) (t t))))) query) -- 2.34.1