More work on a default encoding so that running through cffi-uffi,
authorRuss Tyndall <russ@acceleration.net>
Wed, 11 Jun 2014 19:14:12 +0000 (15:14 -0400)
committerRuss Tyndall <russ@acceleration.net>
Wed, 11 Jun 2014 19:27:58 +0000 (15:27 -0400)
we dont get nil encodings

ChangeLog
db-sqlite3/sqlite3-sql.lisp
sql/database.lisp
sql/pool.lisp

index 7fc08bff427906549f4026fabb612b8421aa0be2..86f7b49928705a35c843bda831742922634347f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-06-11 Russ Tyndall <russ@acceleration.net>
+       * databases.lisp, sqlite3-sql.lisp
+       Similar to and overriding the patch 2014-01-30 937a3d, adds a
+       default-encoding variable uses that in places where a nil encoding
+       was being passed. Defaults to :utf-8.  This is mostly in place so
+       that uffi and cffi both work similarly (by moving the default into
+       clsql instead of clsql-uffi).  This allows my automated build
+       environment to do its job
+
 2014-06-10 Russ Tyndall <russ@acceleration.net>
 
        * db-mysql/Makefile - the results of dpkg-buildflags --get LDFLAGS
index 4f953d013212fc5d63d9dd02026745c7bc8ecb8d..8ce592c6fbe1978f1e0d0ee824b33f4ae9ca05a3 100644 (file)
                                              (sqlite3:sqlite3-column-blob stmt i)
                                              (car types)
                                              :length (sqlite3:sqlite3-column-bytes stmt i)
-                                             :encoding (or (encoding database)
-                                                           :utf-8))
+                                             :encoding (encoding database))
                                             (clsql-uffi:convert-raw-field
                                              (sqlite3:sqlite3-column-text stmt i)
                                              (car types)
-                                             :encoding (or (encoding database)
-                                                           :utf-8))))))
+                                             :encoding (encoding database))))))
                    (when field-names
                      (setf col-names (loop for n from 0 below n-col
                                            collect (sqlite3:sqlite3-column-name stmt n))))
index b860d309f628d4de7001506809d48dbf90ddf712..299eadca439fc07f1c0955c417595cc6eca1650c 100644 (file)
@@ -12,6 +12,9 @@
 
 (in-package #:clsql-sys)
 
+(defvar *default-encoding*
+  (or #+sbcl sb-impl::*default-external-format*
+      :utf-8))
 
 (defvar *connect-if-exists* :error
   "Default value for the if-exists keyword argument in calls to
@@ -73,7 +76,7 @@ error is signalled."
                 (make-default t)
                 (pool nil)
                 (database-type *default-database-type*)
-                (encoding nil))
+                (encoding *default-encoding*))
   "Connects to a database of the supplied DATABASE-TYPE which
 defaults to *DEFAULT-DATABASE-TYPE*, using the type-specific
 connection specification CONNECTION-SPEC. The value of IF-EXISTS,
@@ -315,8 +318,9 @@ system specified by DATABASE-TYPE."
   (database-list connection-spec database-type))
 
 (defun encoding (db)
-  (when (typep db 'database)
-    (slot-value db 'encoding)))
+  (or (when (typep db 'database)
+        (slot-value db 'encoding))
+      *default-encoding*))
 
 (defun (setf encoding) (encoding db)
   (when (typep db 'database)
index 8d73e67dab40a612306629cea582c91b5a76b30b..a153c916707aba2a31ff2b7b0ceabc5f248a6939 100644 (file)
@@ -35,7 +35,7 @@
 
 
 
-(defun acquire-from-pool (connection-spec database-type &optional pool encoding)
+(defun acquire-from-pool (connection-spec database-type &optional pool (encoding *default-encoding*))
   "Try to find a working database connection in the pool or create a new
 one if needed. This performs 1 query against the DB to ensure it's still
 valid. When possible (postgres, mssql) that query will be a reset