[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 208885e264 031/427: Add testing to schema handling
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 208885e264 031/427: Add testing to schema handling. |
Date: |
Tue, 13 Dec 2022 02:59:25 -0500 (EST) |
branch: elpa/emacsql
commit 208885e264df0abdaa55ff7d2a5214c554fc694f
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add testing to schema handling.
---
emacsql-tests.el | 11 +++++++++++
emacsql.el | 4 +++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/emacsql-tests.el b/emacsql-tests.el
index 548eb807b6..481c09c566 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -16,3 +16,14 @@
(should (string= (emacsql-escape-value [1 2 3]) "'[1 2 3]'"))
(should (string= (emacsql-escape-value '(a b c)) "'(a b c)'"))
(should (string= (emacsql-escape-value nil) "NULL")))
+
+(ert-deftest emacsql-schema ()
+ (should (string= (emacsql--schema-to-string [a]) "a"))
+ (should (string= (emacsql--schema-to-string [a b c]) "a, b, c"))
+ (should (string= (emacsql--schema-to-string [a (b)]) "a, b"))
+ (should (string= (emacsql--schema-to-string [a (b float)])
+ "a, b REAL"))
+ (should (string= (emacsql--schema-to-string [a (b :primary float :unique)])
+ "a, b REAL PRIMARY KEY UNIQUE"))
+ (should (string= (emacsql--schema-to-string [(a integer) (b float)])
+ "a INTEGER, b REAL")))
diff --git a/emacsql.el b/emacsql.el
index fd043d7f2f..fa75f38ef5 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -250,10 +250,12 @@ If NAMED is non-nil, don't include column names."
(defun emacsql-create (conn table schema &optional if-not-exists)
"Create TABLE in CONN with SCHEMA."
+ (when (= 0 (length schema))
+ (error "Schema must not be empty."))
(emacsql-with-errors conn
(emacsql--send
conn
- (format "CREATE TABLE %s%s(%s);"
+ (format "CREATE TABLE %s%s (%s);"
(if if-not-exists "IF NOT EXISTS " "")
(emacsql-escape table)
(emacsql--schema-to-string schema)))))
- [nongnu] elpa/emacsql c7597ab813 001/427: Initial commit., (continued)
- [nongnu] elpa/emacsql c7597ab813 001/427: Initial commit., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3b24b5d17c 002/427: Drop closed-p field., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 161e3a41b1 006/427: Add some tests., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 97e9764343 008/427: Change the API of emacsql-insert., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ccfafd7703 012/427: Always quote non-number values., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1074113f03 016/427: Add readability note., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 727f3c8566 022/427: Make nil correspond to NULL., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f8d9511d1d 025/427: Tweak README limitations paragraph., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 2f0a9457a4 029/427: Drop non-idiomatic :else., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4f6b524b9f 026/427: Rename spec to schema., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 208885e264 031/427: Add testing to schema handling.,
ELPA Syncer <=
- [nongnu] elpa/emacsql abe43b3381 043/427: Add :where test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4a89bfaf44 044/427: Use a macro to greatly simplify expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql eb10ddcdba 004/427: Error-free reaping since it's automatic., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a6dbb52a3c 009/427: Add flatten option., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 2053a15b21 010/427: Add Emacs requirement note., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 961c689269 011/427: Rename information to constraints., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c7a8ef0908 015/427: Rename every emacsql argument to conn., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d083cbb70e 017/427: Add in-memory database support., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9091fe8df5 019/427: Rename sqlite-program-name into namespace., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9c3293c57e 020/427: Add a docstring to emacsql struct., ELPA Syncer, 2022/12/13