Skip to content

Commit

Permalink
Rename fetch-dao to fetch-dao-from-cursor and unexport it.
Browse files Browse the repository at this point in the history
  • Loading branch information
fukamachi committed Aug 7, 2024
1 parent c0100e1 commit 9de6e42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions src/core/dao.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
#:delete-by-values
#:save-dao
#:select-dao
#:*want-cursor*
#:fetch-dao
#:select-by-sql
#:includes
#:include-foreign-objects
Expand Down Expand Up @@ -216,8 +214,7 @@
(make-mito-cursor :cursor cursor
:class class))))

(defun fetch-dao (cursor)
(check-type cursor mito-cursor)
(defun fetch-dao-from-cursor (cursor)
(let ((row (dbi:fetch (mito-cursor-cursor cursor)
:format :alist)))
(when row
Expand Down Expand Up @@ -456,7 +453,7 @@
(let* ((*want-cursor* t)
(,cursor ,select))
(loop ,@(and index `(for ,index from 0))
for ,dao = (fetch-dao ,cursor)
for ,dao = (fetch-dao-from-cursor ,cursor)
while ,dao
do (progn ,@body)))))
(if (dbi:in-transaction *connection*)
Expand Down
8 changes: 4 additions & 4 deletions t/dao.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,17 @@
(mito:create-dao 'user :name "Btaro")
(mito:create-dao 'user :name "Charlie")
(dbi:with-transaction *connection*
(let* ((*want-cursor* t)
(let* ((mito.dao::*want-cursor* t)
(cursor (mito.dao:select-dao 'user
(where (:like :name "%aro")))))
(ok (typep cursor 'mito.dao::mito-cursor))
(let ((row (mito.dao:fetch-dao cursor)))
(let ((row (mito.dao::fetch-dao-from-cursor cursor)))
(ok (typep row 'user))
(ok (equal (slot-value row 'name) "Eitaro")))
(let ((row (mito.dao:fetch-dao cursor)))
(let ((row (mito.dao::fetch-dao-from-cursor cursor)))
(ok (typep row 'user))
(ok (equal (slot-value row 'name) "Btaro")))
(ok (null (mito.dao:fetch-dao cursor)))))
(ok (null (mito.dao::fetch-dao-from-cursor cursor)))))

(let ((records '()))
(do-cursor (dao (mito.dao:select-dao 'user) i)
Expand Down

0 comments on commit 9de6e42

Please sign in to comment.