Permalink
Browse files

changed `execute' to always returns an instance of <dbd-query>.

  • Loading branch information...
1 parent 19af9d1 commit 6057501f6035cf4eaa2f1fd94b03441cf4ad58b9 @fukamachi committed Dec 19, 2011
Showing with 11 additions and 21 deletions.
  1. +1 −15 src/driver.lisp
  2. +10 −6 src/test.lisp
View
@@ -91,23 +91,9 @@ This method may be overrided by subclasses."
query
params))
-@export
-(defgeneric fetch (result)
- (:documentation "Fetch the first row from `result` which is returned by `execute`."))
-
-@export
-(defmethod fetch ((result list))
- (pop result))
-
-@export
-(defmethod fetch ((result vector))
- (handler-case (vector-pop result)
- (simple-error (condition)
- @ignore condition
- nil)))
-
@export
(defmethod fetch ((query <dbd-query>))
+ "Fetch the first row from `query` which is returned by `execute`."
(fetch-using-connection (query-connection query) query))
@export
View
@@ -19,7 +19,7 @@
@export
(defun run-driver-tests (driver-name &rest params)
(let ((*db* (apply #'connect driver-name params)))
- (plan 15)
+ (plan 17)
(run-test-all)))
(deftest |connect|
@@ -39,18 +39,22 @@
(setf query (prepare *db* "SELECT * FROM person"))
(is-type query '<dbd-query>)
(setf result (execute query))
- (ok result)
- (ok (property-list-p (fetch result)))
- (ok (property-list-p (fetch result)))
+ (is-type result '<dbd-query>)
+ (let ((result (fetch result)))
+ (is-type result 'property-list)
+ (is (getf result :|name|) "fukamachi"))
+ (let ((result (fetch result)))
+ (is-type result 'property-list)
+ (is (getf result :|name|) "matsuyama"))
(is (fetch result) nil)))
(deftest |place holder|
(let (query result)
(setf query (prepare *db* "SELECT * FROM person WHERE name = ?"))
(is-type query '<dbd-query>)
(setf result (execute query "matsuyama"))
- (ok result)
- (ok (property-list-p (fetch result)))
+ (is-type result '<dbd-query>)
+ (is-type (fetch result) 'property-list)
(is (fetch result) nil)))
(deftest |with-transaction|

0 comments on commit 6057501

Please sign in to comment.