[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 0f0840ffbf 128/427: Add :default column constraint
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 0f0840ffbf 128/427: Add :default column constraint. |
Date: |
Tue, 13 Dec 2022 02:59:35 -0500 (EST) |
branch: elpa/emacsql
commit 0f0840ffbf576a49783eefa2a4b7bb916952349b
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add :default column constraint.
---
README.md | 5 +++--
emacsql-tests.el | 4 ++++
emacsql.el | 2 ++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index a82a88c6cc..af7699f187 100644
--- a/README.md
+++ b/README.md
@@ -58,8 +58,9 @@ symbol or it can include constraints, such as type and
uniqueness.
Because Emacsql stores entire lisp objects as values, the only
relevant types are `integer`, `float`, and `object` (default).
-Additional constraints include `:primary` (aka `PRIMARY KEY`),
-`:unique` (aka `UNIQUE`), `:non-nil` (aka `NOT NULL`).
+Additional columns constraints include `:primary` (aka `PRIMARY KEY`),
+`:unique` (aka `UNIQUE`), `:non-nil` (aka `NOT NULL`), `:default` (aka
+`DEFAULT`).
```el
;; Example schema:
diff --git a/emacsql-tests.el b/emacsql-tests.el
index 3d048e3849..dac5793f89 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -76,6 +76,10 @@
"CREATE TABLE foo (a, b, c);")
([:create-table (:temporary :if-not-exists x) [y]] '()
"CREATE TEMPORARY TABLE IF NOT EXISTS x (y);")
+ ([:create-table foo [(a :default 10)]] '()
+ "CREATE TABLE foo (a DEFAULT 10);")
+ ([:create-table foo [(a :primary :non-nil) b]] '()
+ "CREATE TABLE foo (a PRIMARY KEY NOT NULL, b);")
([:drop-table $1] '(foo)
"DROP TABLE foo;")))
diff --git a/emacsql.el b/emacsql.el
index 71206e71ab..8861f25ec7 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -275,6 +275,8 @@ CONN-SPEC is a connection specification like the call to
(:primary (push "PRIMARY KEY" output))
(:non-nil (push "NOT NULL" output))
(:unique (push "UNIQUE" output))
+ (:default (push "DEFAULT" output)
+ (push (emacsql-escape-value (pop column)) output))
(integer (setf type "INTEGER"))
(float (setf type "REAL"))
(object (setf type "TEXT"))
- [nongnu] elpa/emacsql 00bb81ff2b 266/427: Fix Makefile typo., (continued)
- [nongnu] elpa/emacsql 00bb81ff2b 266/427: Fix Makefile typo., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c8de0ff1fd 293/427: Adjust the EmacSQL protocol., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 51224aab7a 288/427: Add unit test for last change., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c5845884f4 021/427: Rename type to column., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 7caa63c11e 023/427: Allow any sequence for table spec., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 963f221b82 049/427: Add expr expansion function., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 109664b88b 060/427: Memoize emacsql-expand., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1fb97f7d4a 092/427: Drop unusable macro emacsql-with-connection., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql add06c47b9 117/427: Bring back :into for :replace (oops!)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d7a05db54e 080/427: Add :replace expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 0f0840ffbf 128/427: Add :default column constraint.,
ELPA Syncer <=
- [nongnu] elpa/emacsql bbe3031a50 130/427: Add table constraints., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 53b2e98515 131/427: Fill out README for new schema table constraints., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 364c3cacb6 133/427: More advanced :from sources, again., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 99a8069389 135/427: Add support for foreign keys., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e6ab07e16b 140/427: Switch to a friendlier name., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql bec6af6940 148/427: Add VACUUM., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 03aebdecd1 160/427: Rename :log option to :debug., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql bb221f6134 161/427: Drop .print command flushing., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 72b34f6522 173/427: Add some more autoloading., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3229cd41af 180/427: Change the requirements for front-end implementations., ELPA Syncer, 2022/12/13