From: Alexander Gavrilov Date: Sat, 30 Oct 2010 09:37:56 +0000 (+0400) Subject: Fix a couple of minor issues in the library. X-Git-Tag: 0.2~5 X-Git-Url: https://repo.or.cz/w/cl-sqlite.git/commitdiff_plain/f7cf544837a37df20910c9f4cbedfe4d6c0a8c80 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. --- 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)))