[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 963f221b82 049/427: Add expr expansion function.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 963f221b82 049/427: Add expr expansion function. |
Date: |
Tue, 13 Dec 2022 02:59:27 -0500 (EST) |
branch: elpa/emacsql
commit 963f221b826254906c97e97235c3ca708fcbec38
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add expr expansion function.
---
emacsql.el | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/emacsql.el b/emacsql.el
index faa727a17d..9a0d7521f6 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -393,6 +393,27 @@ definitions for return from a `emacsql-defexpander'."
(symbol-function 'emacsql--vars-combine)))
(cons (concat ,prefix (progn ,@body)) emacsql--vars))))
+(defun emacsql--expr (expr)
+ "Expand EXPR recursively."
+ (emacsql-with-vars ""
+ (if (atom expr)
+ (var expr :auto)
+ (cl-destructuring-bind (op . args) expr
+ (cl-flet ((recur (n) (combine (emacsql--expr (nth n args)))))
+ (cl-ecase op
+ ((<= >=)
+ (cl-ecase (length args)
+ (2 (format "%s %s %s" (recur 0) op (recur 1)))
+ (3 (format "%s BETWEEN %s AND %s"
+ (recur 1)
+ (recur (if (eq op '<=) 2 0))
+ (recur (if (eq op '<=) 0 2))))))
+ ((< > = != like glob is and or * / % << >> + - & |)
+ (format "%s %s %s"
+ (recur 0)
+ (upcase (symbol-name op))
+ (recur 1)))))))))
+
;; SQL Expansion Functions:
(emacsql-defexpander :select (arg)
- [nongnu] elpa/emacsql db0159f138 032/427: Update README., (continued)
- [nongnu] elpa/emacsql db0159f138 032/427: Update README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 801bc6239f 222/427: Swap the tuple order., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9e6ea00f01 243/427: Add note about PostgreSQL., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ad6c09681e 261/427: Oops, print the tuple., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ff59ca9336 265/427: Clear out binaries in distclean, too., ELPA Syncer, 2022/12/13
- [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 <=
- [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, 2022/12/13
- [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