[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
- [nongnu] elpa/emacsql d04ef64ce0 109/427: Add IF NOT EXISTS and TEMPORARY to CREATE TABLE., (continued)
- [nongnu] elpa/emacsql d04ef64ce0 109/427: Add IF NOT EXISTS and TEMPORARY to CREATE TABLE., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 58641b9827 115/427: Fill out keywords in README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fc941d7c75 118/427: Capture a common identifier vector pattern., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a09911a205 125/427: Add LIMIT and OFFSET expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8945af0dd8 129/427: Add :check and allow schemas to have variables., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4206b17f39 134/427: Add support for AS with CREATE TABLE., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6c32f02139 137/427: Add emacsql-thread macro., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 54c180017e 138/427: Add :pragma and note in README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5e2ab842f7 139/427: Add foreign key test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 42c2fd7569 145/427: Tweak limitation wording., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fe0c7004fc 146/427: Add :begin, :commit, and :rollback.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 2550196816 162/427: Drop SQLite version requirements., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9a1b4209ba 164/427: Add PostgreSQL front-end., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5f4c2ed5a7 166/427: Add emacsql-psql-unavailable-p., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1d0ef4011c 167/427: Make emacsql-connection abstract., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 64c3a03d62 169/427: Flesh out some more README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9f6c10eca0 172/427: Move error checking out to helper mix-in., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4f76b94f7c 168/427: Set psql to print nil for NULL., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 7434263d82 174/427: Oops, drop leftover function call., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ca62adc4b2 177/427: Add debug argument to emacsql-psql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql afef528d81 179/427: Fix memoization to include type map., ELPA Syncer, 2022/12/13