Skip to content

Commit

Permalink
modified to use the same letter case for error-code symbols and run-a…
Browse files Browse the repository at this point in the history
…ll-tests function.
  • Loading branch information
kmizumar committed Mar 25, 2012
1 parent c738e66 commit b4261c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sqlite.asd
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
:in-order-to ((test-op (load-op sqlite-tests))))

(defmethod perform ((o asdf:test-op) (c (eql (find-system :sqlite))))
(funcall (intern "RUN-ALL-TESTS" :sqlite-tests)))
(funcall (intern "run-all-tests" :sqlite-tests)))
18 changes: 9 additions & 9 deletions sqlite.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
statement
(db-handle (if statement (db statement)))
(sql-text (if statement (sql statement))))
(error (if (eq error-code :constraint)
(error (if (eq error-code :CONSTRAINT)
'sqlite-constraint-error
'sqlite-error)
:format-control (if (listp message) (first message) message)
Expand Down Expand Up @@ -91,7 +91,7 @@
(defmethod initialize-instance :after ((object sqlite-handle) &key (database-path ":memory:") &allow-other-keys)
(cffi:with-foreign-object (ppdb 'sqlite-ffi:p-sqlite3)
(let ((error-code (sqlite-ffi:sqlite3-open database-path ppdb)))
(if (eq error-code :ok)
(if (eq error-code :OK)
(setf (handle object) (cffi:mem-ref ppdb 'sqlite-ffi:p-sqlite3)
(database-path object) database-path)
(sqlite-error error-code (list "Could not open sqlite3 database ~A" database-path)))))
Expand Down Expand Up @@ -120,7 +120,7 @@
(for statement in statements)
(really-finalize-statement statement))
(let ((error-code (sqlite-ffi:sqlite3-close (handle handle))))
(unless (eq error-code :ok)
(unless (eq error-code :OK)
(sqlite-error error-code "Could not close sqlite3 database." :db-handle handle))
(slot-makunbound handle 'handle)))

Expand All @@ -139,7 +139,7 @@
(cffi:with-foreign-object (p-tail '(:pointer :char))
(cffi:with-foreign-string (sql (sql object))
(let ((error-code (sqlite-ffi:sqlite3-prepare (handle (db object)) sql -1 p-statement p-tail)))
(unless (eq error-code :ok)
(unless (eq error-code :OK)
(sqlite-error error-code "Could not prepare an sqlite statement."
:db-handle (db object) :sql-text (sql object)))
(unless (zerop (cffi:mem-ref (cffi:mem-ref p-tail '(:pointer :char)) :uchar))
Expand Down Expand Up @@ -190,21 +190,21 @@ Note: does not immediately release resources because statements are cached."
Returns T is successfully advanced to the next row and NIL if there are no more rows."
(let ((error-code (sqlite-ffi:sqlite3-step (handle statement))))
(case error-code
(:done nil)
(:row t)
(:DONE nil)
(:ROW t)
(t
(sqlite-error error-code "Error while stepping an sqlite statement." :statement statement)))))

(defun reset-statement (statement)
"Resets the STATEMENT and prepare it to be called again."
(let ((error-code (sqlite-ffi:sqlite3-reset (handle statement))))
(unless (eq error-code :ok)
(unless (eq error-code :OK)
(sqlite-error error-code "Error while resetting an sqlite statement." :statement statement))))

(defun clear-statement-bindings (statement)
"Sets all binding values to NULL."
(let ((error-code (sqlite-ffi:sqlite3-clear-bindings (handle statement))))
(unless (eq error-code :ok)
(unless (eq error-code :OK)
(sqlite-error error-code "Error while clearing bindings of an sqlite statement."
:statement statement))))

Expand Down Expand Up @@ -398,7 +398,7 @@ Supported types:
(list "Do not know how to pass value ~A of type ~A to sqlite."
value (type-of value))
:statement statement)))))
(unless (eq error-code :ok)
(unless (eq error-code :OK)
(sqlite-error error-code
(list "Error when binding parameter ~A to value ~A." parameter value)
:statement statement)))))
Expand Down

0 comments on commit b4261c1

Please sign in to comment.