emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/emacsql fe0c7004fc 146/427: Add :begin, :commit, and :roll


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql fe0c7004fc 146/427: Add :begin, :commit, and :rollback.
Date: Tue, 13 Dec 2022 02:59:36 -0500 (EST)

branch: elpa/emacsql
commit fe0c7004fc0c021bc94c8d0ebe60c8455aacfa2d
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>

    Add :begin, :commit, and :rollback.
---
 README.md        | 19 +++++++++++++++++++
 emacsql-tests.el | 11 +++++++++++
 emacsql.el       | 14 ++++++++++++++
 3 files changed, 44 insertions(+)

diff --git a/README.md b/README.md
index f8a0ff9e8d..4d6dcb0ac0 100644
--- a/README.md
+++ b/README.md
@@ -287,6 +287,25 @@ Provides `UNION`, `UNION ALL`, `DIFFERENCE`, and `EXCEPT`.
 [:select * :from sales :union :select * :from accounting]
 ```
 
+#### :begin `<:transaction|:immediate|:deferred|:exclusive>`
+
+Provides `BEGIN`. Exactly one of these "arguments" must always be
+supplied. `:deferred` and `:transaction` are aliases.
+
+```el
+[:begin :transaction]
+[:begin :immediate]
+```
+
+#### :commit, :rollback
+
+Provides `COMMIT` and `ROLLBACK`.
+
+```el
+[:commit]
+[:rollback]
+```
+
 #### :pragma `<expr>`
 
 Provides `PRAGMA`.
diff --git a/emacsql-tests.el b/emacsql-tests.el
index b4edd8c2bb..cb383f563f 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -163,6 +163,17 @@
     ([:values [a $$1]] '()
      "VALUES ('a', '$1');")))
 
+(ert-deftest emacsql-transaction ()
+  (emacsql-tests-with-queries
+    ([:begin :transaction] '()
+     "BEGIN TRANSACTION;")
+    ([:begin :immediate] '()
+     "BEGIN IMMEDIATE;")
+    ([:rollback] '()
+     "ROLLBACK;")
+    ([:commit] '()
+     "COMMIT;")))
+
 (ert-deftest emacsql-system ()
   "A short test that fully interacts with SQLite."
   (should-not (emacsql-sqlite3-unavailable-p))
diff --git a/emacsql.el b/emacsql.el
index e995f8bce4..6cff8a905a 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -690,6 +690,20 @@ definitions for return from a `emacsql-defexpander'."
   (emacsql-with-vars "PRAGMA "
     (expr expr)))
 
+(emacsql-defexpander :begin (kind)
+  (emacsql-with-vars "BEGIN "
+    (cl-ecase kind
+      (:transaction "TRANSACTION")
+      (:deferred    "DEFERRED")
+      (:immediate   "IMMEDIATE")
+      (:exclusive   "EXCLUSIVE"))))
+
+(emacsql-defexpander :commit ()
+  (list "COMMIT"))
+
+(emacsql-defexpander :rollback ()
+  (list "ROLLBACK"))
+
 (provide 'emacsql)
 
 ;;; emacsql.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]