branch: elpa/emacsql commit dcb9a903c73e558fb4536fa4fcb42273ed73e6d5 Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@nullprogram.com>
Put emacsql-thread inside a transaction. --- emacsql.el | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/emacsql.el b/emacsql.el index 7a6857fef0..297cf0bb25 100644 --- a/emacsql.el +++ b/emacsql.el @@ -240,17 +240,6 @@ CONNECTION-SPEC establishes a single binding. (progn ,@body) (emacsql-close ,(car connection-spec))))) -(defmacro emacsql-thread (connection &rest statements) - "Thread CONNECTION through STATEMENTS. -A statement can be a list, containing a statement with its arguments." - (declare (indent 1)) - `(let ((emacsql--conn ,connection)) - ,@(cl-loop for statement in statements - when (vectorp statement) - collect (list 'emacsql 'emacsql--conn statement) - else - collect (append (list 'emacsql 'emacsql--conn) statement)))) - (defvar emacsql--transaction-level 0 "Keeps track of nested transactions in `emacsql-with-transaction'.") @@ -275,6 +264,18 @@ single transaction at the lowest level." (not emacsql--completed)) (emacsql emacsql--connection [:rollback]))))) +(defmacro emacsql-thread (connection &rest statements) + "Thread CONNECTION through STATEMENTS. +A statement can be a list, containing a statement with its arguments." + (declare (indent 1)) + `(let ((emacsql--conn ,connection)) + (emacsql-with-transaction emacsql--conn + ,@(cl-loop for statement in statements + when (vectorp statement) + collect (list 'emacsql 'emacsql--conn statement) + else + collect (append (list 'emacsql 'emacsql--conn) statement))))) + (defmacro emacsql-with-bind (connection sql-and-args &rest body) "For each result row bind the column names for each returned row. Returns the result of the last evaluated BODY.