diff --git a/src/dbd/postgres.lisp b/src/dbd/postgres.lisp index 14532ef..f9ce6a0 100644 --- a/src/dbd/postgres.lisp +++ b/src/dbd/postgres.lisp @@ -200,11 +200,11 @@ (next-field field)) finally (return hash)))) -(defmethod fetch ((cursor dbi-cursor) &key (format :plist)) +(defmethod fetch-using-connection ((conn dbd-postgres-connection) (cursor dbi-cursor) format) (unless (cursor-declared-p cursor) (error "The cursor is not declared yet.")) (first - (exec-query (connection-handle (cursor-connection cursor)) + (exec-query (connection-handle conn) (format nil "FETCH ~A" (cursor-name cursor)) (ecase format (:plist @@ -216,7 +216,8 @@ (:values 'cl-postgres:list-row-reader))))) -(defmethod fetch ((query dbd-postgres-query) &key (format :plist)) +(defmethod fetch-using-connection ((conn dbd-postgres-connection) (query dbi-query) format) + (declare (ignore conn)) (let ((fields (query-fields query)) (row (pop (query-results query)))) (ecase format diff --git a/src/driver.lisp b/src/driver.lisp index 713b63f..c15fb11 100644 --- a/src/driver.lisp +++ b/src/driver.lisp @@ -205,7 +205,9 @@ This method may be overrided by subclasses." (defgeneric fetch (query &key format) (:documentation "Fetch the first row from `query` which is returned by `execute`.") (:method ((query dbi-query) &key (format *row-format*)) - (fetch-using-connection (query-connection query) query format))) + (fetch-using-connection (query-connection query) query format)) + (:method ((cursor dbi-cursor) &key (format *row-format*)) + (fetch-using-connection (cursor-connection cursor) cursor format))) (defgeneric fetch-all (query &key format) (:documentation "Fetch all rest rows from `query`.")