Skip to content

Commit

Permalink
Stop defining 'fetch' directly in postgres driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
fukamachi committed Aug 7, 2024
1 parent 629abec commit 48fa6fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/dbd/postgres.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/driver.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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`.")
Expand Down

0 comments on commit 48fa6fb

Please sign in to comment.