From f7cf544837a37df20910c9f4cbedfe4d6c0a8c80 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 30 Oct 2010 13:37:56 +0400 Subject: [PATCH] Fix a couple of minor issues in the library. - If error-code is NIL, error message is undefined too. - Prepare-statement should clear bindings when using cache, or the result won't be identical in behavior to a new object. --- sqlite.lisp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sqlite.lisp b/sqlite.lisp index af54377..a8f3982 100644 --- a/sqlite.lisp +++ b/sqlite.lisp @@ -56,7 +56,7 @@ :format-arguments (if (listp message) (rest message)) :db-handle db-handle :error-code error-code - :error-msg (if db-handle + :error-msg (if (and db-handle error-code) (sqlite-ffi:sqlite3-errmsg (handle db-handle))) :statement statement :sql sql-text)) @@ -161,7 +161,10 @@ SQL may have some positional (not named) parameters specified with question mark Example: select name from users where id = ?" - (or (sqlite.cache:get-from-cache (cache db) sql) + (or (let ((statement (sqlite.cache:get-from-cache (cache db) sql))) + (when statement + (clear-statement-bindings statement)) + statement) (let ((statement (make-instance 'sqlite-statement :db db :sql sql))) (push statement (sqlite-handle-statements db)) statement))) -- 2.11.4.GIT