[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql c9aab20d47 082/427: Add in operator (special case
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql c9aab20d47 082/427: Add in operator (special case operator). |
Date: |
Tue, 13 Dec 2022 02:59:30 -0500 (EST) |
branch: elpa/emacsql
commit c9aab20d476ca9dd67cbbb0ddedcafc23a59c197
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add in operator (special case operator).
---
README.md | 2 +-
emacsql-tests.el | 4 +++-
emacsql.el | 7 ++++++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 7e232caa20..89b8603025 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ exactly like so in a structured Emacsql statement.
* / % + - << >> &
| < <= > >= = !=
- is like glob and or
+ is like glob and or in
The `<=` and `>=` operators accept 2 or 3 operands, transforming into
a SQL `_ BETWEEN _ AND _` operator as appropriate.
diff --git a/emacsql-tests.el b/emacsql-tests.el
index 41ebd4eb74..ac96be14b2 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -65,7 +65,9 @@
(emacsql-tests-query [:drop-table $1] '(foo)
"DROP TABLE foo;")
(emacsql-tests-query [:update people :set (= id $1)] '(10)
- "UPDATE people SET id = 10;"))
+ "UPDATE people SET id = 10;")
+ (emacsql-tests-query [:select * :from people :where (in name $1)] '([FOO
BAR])
+ "SELECT * FROM people WHERE name IN ('FOO', 'BAR');"))
(provide 'emacsql-tests)
diff --git a/emacsql.el b/emacsql.el
index 4ba13c93c3..1fde40847e 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -426,7 +426,12 @@ definitions for return from a `emacsql-defexpander'."
((-)
(cl-ecase (length args)
(1 (format "-(%s)" (recur 0)))
- (2 (format "%s - %s" (recur 0) (recur 1)))))))))))
+ (2 (format "%s - %s" (recur 0) (recur 1)))))
+ ;; IN special case
+ ((in)
+ (if (= 2 (length args))
+ (format "%s IN %s" (recur 0)
+ (var (nth 1 args) :vector))))))))))
;; SQL Expansion Functions:
- [nongnu] elpa/emacsql 3eb06cdd73 114/427: Add GROUP BY expander., (continued)
- [nongnu] elpa/emacsql 3eb06cdd73 114/427: Add GROUP BY expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e08094c78f 058/427: More precise parsing., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b9599f1f41 066/427: Spelling error., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f410b5d663 068/427: Fix spelling error., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b3110c9fa9 018/427: Rename .sqlite to .db., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 031ec59f18 048/427: Add combine function to with-vars macro., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f9820deed7 056/427: Add unary operators., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f9c562b0a4 069/427: Add SQLite link., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 43ecb5a252 071/427: Tweak README names., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 58e31aa3a9 079/427: Add :update and :set expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c9aab20d47 082/427: Add in operator (special case operator).,
ELPA Syncer <=
- [nongnu] elpa/emacsql 25f9817064 094/427: Add work-in-progress note back., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 03295cba37 119/427: Add ORDER BY expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d1c0904564 120/427: Fix missing quotes., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4718ff4e89 122/427: Simplify all the expanders with new local functions., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 54247e4b5e 127/427: Add another insertion unit test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql aa9283ca0a 132/427: Allow sub-selects with :from., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c236aa8437 144/427: Remove extra space., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 75ea77c9a0 149/427: Add an "as" operator, greatly simplifying :from., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 213bb71b7a 152/427: Add :having expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8123020ca7 153/427: Make and and or operators variadic., ELPA Syncer, 2022/12/13