[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 8b2cf8c208 041/427: Fix up :where.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 8b2cf8c208 041/427: Fix up :where. |
Date: |
Tue, 13 Dec 2022 02:59:26 -0500 (EST) |
branch: elpa/emacsql
commit 8b2cf8c2083df74317eb6f1c97a7e8ad0d891599
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Fix up :where.
---
emacsql.el | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/emacsql.el b/emacsql.el
index e130a531a2..b5ccb82a6b 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -328,11 +328,15 @@ and should return a list of (<string> [arg-pos] ...)."
(cl-destructuring-bind (format . vars) expansion
(apply #'format format
(cl-loop for (i . kind) in vars collect
- (cl-ecase kind
- (:identifier (emacsql-escape (nth i args)))
- (:value (emacsql-escape-value (nth i args))))))))
-
-(defun emacsql (conn sql &optional args)
+ (let ((thing (nth i args)))
+ (cl-ecase kind
+ (:identifier (emacsql-escape thing))
+ (:value (emacsql-escape-value thing))
+ (:auto (if (symbolp thing)
+ (emacsql-escape thing)
+ (emacsql-escape-value thing)))))))))
+
+(defun emacsql (conn sql &rest args)
"Send structured SQL expression to CONN with ARGS."
(emacsql--clear conn)
(emacsql--send conn (apply #'emacsql-format (emacsql-expand sql) args))
@@ -393,18 +397,18 @@ KIND should be :value or :identifier."
(emacsql-defexpander :where (expr)
(let ((vars ()))
- (cl-flet* ((collect (thing kind)
- (push (cons (emacsql-var thing) kind) vars) "%s")
+ (cl-flet* ((collect (thing)
+ (push (cons (emacsql-var thing) :auto) vars) "%s")
(handle (v)
(cond ((emacsql-var v) (collect v))
((symbolp v) (emacsql-escape-format v :identifier))
- ((emacsql-escape-value v)))))
+ ((emacsql-escape-format v :value)))))
(cl-destructuring-bind (op a b) expr
(cons (format "WHERE %s %s %s"
(handle a)
op
(handle b))
- vars)))))
+ (nreverse vars))))))
(provide 'emacsql)
- [nongnu] elpa/emacsql d083cbb70e 017/427: Add in-memory database support., (continued)
- [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
- [nongnu] elpa/emacsql 178a31d5ca 024/427: Lock in the coding system., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 85076dfe0f 027/427: Flesh out example more., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c9854331c0 028/427: Add (un)license header., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 896bb7ce52 035/427: Start adding SQL expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9272d13ace 036/427: Add some tests for the expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3511a0df1d 037/427: Add a top-level query function, emacsql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 7e18a43da1 039/427: Add a template example., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8b2cf8c208 041/427: Fix up :where.,
ELPA Syncer <=
- [nongnu] elpa/emacsql c92c56ce55 003/427: Add a close buffer sentinel., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1a84c983cf 013/427: No named results by default., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 76a430032e 014/427: Fix up old test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 36c6aae4b5 042/427: Drop raw select., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 77ae713186 046/427: Create table expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e859204451 064/427: Flesh out more README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 35676bb560 065/427: Fix README examples., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 847f3bd87f 078/427: Add new keywords to listing., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a9b9d6bfc8 083/427: Fix typo in README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 29f65b3b8e 093/427: Update Windows statement in the README., ELPA Syncer, 2022/12/13