From: Russ Tyndall Date: Wed, 11 Jun 2014 19:14:12 +0000 (-0400) Subject: More work on a default encoding so that running through cffi-uffi, X-Git-Tag: v6.6.0~6 X-Git-Url: http://git.kpe.io/?p=clsql.git;a=commitdiff_plain;h=326e9dc298298431a7122ed57d14a60bccd95923 More work on a default encoding so that running through cffi-uffi, we dont get nil encodings --- diff --git a/ChangeLog b/ChangeLog index 7fc08bf..86f7b49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-06-11 Russ Tyndall + * 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 * db-mysql/Makefile - the results of dpkg-buildflags --get LDFLAGS diff --git a/db-sqlite3/sqlite3-sql.lisp b/db-sqlite3/sqlite3-sql.lisp index 4f953d0..8ce592c 100644 --- a/db-sqlite3/sqlite3-sql.lisp +++ b/db-sqlite3/sqlite3-sql.lisp @@ -205,13 +205,11 @@ (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)))) diff --git a/sql/database.lisp b/sql/database.lisp index b860d30..299eadc 100644 --- a/sql/database.lisp +++ b/sql/database.lisp @@ -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) diff --git a/sql/pool.lisp b/sql/pool.lisp index 8d73e67..a153c91 100644 --- a/sql/pool.lisp +++ b/sql/pool.lisp @@ -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