[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql d04ef64ce0 109/427: Add IF NOT EXISTS and TEMPORAR
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql d04ef64ce0 109/427: Add IF NOT EXISTS and TEMPORARY to CREATE TABLE. |
Date: |
Tue, 13 Dec 2022 02:59:33 -0500 (EST) |
branch: elpa/emacsql
commit d04ef64ce0f3415c4e4b6e34979935fa2dfa20a6
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add IF NOT EXISTS and TEMPORARY to CREATE TABLE.
---
README.md | 1 +
emacsql.el | 14 +++++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index dfbf1a6438..77fea6ca74 100644
--- a/README.md
+++ b/README.md
@@ -116,6 +116,7 @@ Provides `CREATE TABLE`.
```el
[:create-table employees [name (id integer :primary) (salary float)]]
+[:create-table (:temporary :if-not-exists employees) ...]
```
#### :drop-table `<table>`
diff --git a/emacsql.el b/emacsql.el
index e946a29422..9335f45cbf 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -501,9 +501,17 @@ definitions for return from a `emacsql-defexpander'."
(combine (emacsql--expr expr))))
(emacsql-defexpander :create-table (table schema)
- (emacsql-with-vars "CREATE TABLE "
- (format "%s (%s)" (var table :identifier)
- (emacsql--schema-to-string schema))))
+ (emacsql-with-vars "CREATE "
+ (let (temporary if-not-exists name)
+ (dolist (item (if (listp table) table (list table)))
+ (cl-case item
+ (:if-not-exists (setf if-not-exists "IF NOT EXISTS"))
+ (:temporary (setf temporary "TEMPORARY"))
+ (otherwise (setf name (var item :identifier)))))
+ (let* ((items (list temporary "TABLE" if-not-exists name))
+ (spec (remove-if-not #'identity items)))
+ (format "%s (%s)" (mapconcat #'identity spec " ")
+ (emacsql--schema-to-string schema))))))
(emacsql-defexpander :drop-table (table)
(emacsql-with-vars "DROP TABLE "
- [nongnu] elpa/emacsql 2ffcc95c67 338/427: Fix a typo in the doc-string of emacsql-with-params., (continued)
- [nongnu] elpa/emacsql 2ffcc95c67 338/427: Fix a typo in the doc-string of emacsql-with-params., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 74bd11bc09 334/427: Fix up package description headers., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5df2891557 349/427: Use cl-generic package, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e8c090e11f 353/427: Improve Makefile portability and dump Cask, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 0ba12b89d5 084/427: Drop "work in progress.", ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 364bf466ea 086/427: Linkify the issue in the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql dd3f153406 089/427: Drop old with-errors macro., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 72c1954517 096/427: Block on connection until the output has flushed., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1e9857ccc4 103/427: Allow variables inside vectors., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8a66563af6 105/427: Combine :insert and :into., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d04ef64ce0 109/427: Add IF NOT EXISTS and TEMPORARY to CREATE TABLE.,
ELPA Syncer <=
- [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, 2022/12/13