[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 672963ae53 191/427: Add DISTINCT option to :select
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 672963ae53 191/427: Add DISTINCT option to :select. |
Date: |
Tue, 13 Dec 2022 02:59:40 -0500 (EST) |
branch: elpa/emacsql
commit 672963ae533cb30f57774ab80ae20567cb26f89b
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add DISTINCT option to :select.
---
README.md | 3 ++-
emacsql-compiler.el | 14 +++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 885aa8380c..dd81a92cf6 100644
--- a/README.md
+++ b/README.md
@@ -191,7 +191,7 @@ Provides `DROP TABLE`.
[:drop-table employees]
```
-#### :select `<column-spec>`
+#### :select `<column-spec>|(:distinct <column-spec>)`
Provides `SELECT`. `column-spec` can be a `*` symbol or a vector of
column identifiers, optionally as expressions.
@@ -199,6 +199,7 @@ column identifiers, optionally as expressions.
```el
[:select [name (/ salary 52)] ...]
[:select [(as name n) (as age a)] ...]
+[:select (:distinct [name age id]) ...]
```
#### :from `<table>`
diff --git a/emacsql-compiler.el b/emacsql-compiler.el
index db24fbb9f0..0d21aa7554 100644
--- a/emacsql-compiler.el
+++ b/emacsql-compiler.el
@@ -374,9 +374,17 @@ definitions for return from a `emacsql-defexpander'."
(emacsql-defexpander :select (arg)
"Expands to the SELECT keyword."
(emacsql-with-vars "SELECT "
- (if (eq '* arg)
- "*"
- (idents arg))))
+ (cond ((eq '* arg)
+ "*")
+ ((listp arg)
+ (cl-case (length arg)
+ (1 (idents (car arg)))
+ (2 (cl-case (car arg)
+ (:distinct (concat "DISTINCT " (idents (cadr arg))))
+ (:all (concat "ALL " (idents (cadr arg))))
+ (otherwise (emacsql-error "Invalid SELECT: %S" (car arg)))))
+ (otherwise (emacsql-error "Invalid SELECT idents: %S" arg))))
+ ((idents arg)))))
(emacsql-defexpander :from (sources)
"Expands to the FROM keyword."
- [nongnu] elpa/emacsql 458b8a6acd 074/427: Add :insert and :values expanders., (continued)
- [nongnu] elpa/emacsql 458b8a6acd 074/427: Add :insert and :values expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 2faed63b20 107/427: Prime emacsql-expand for substatements., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 13cfbeeaba 186/427: Tidy up the constructors., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a742687cfb 192/427: Add funcall operator., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8fa1ca451c 238/427: Fix schema mistake in unit test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ea613c5191 360/427: Push other sub-packages up to Emacs 25 as well, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fbda94e6b5 339/427: Improve some doc-strings., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6f1e375a2e 367/427: Better escaping of NUL and control characters (#42), ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3dc6971829 190/427: Add ALTER TABLE stuff., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ef976b8649 189/427: Add package target for Makefile., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 672963ae53 191/427: Add DISTINCT option to :select.,
ELPA Syncer <=
- [nongnu] elpa/emacsql b1da2ba9d2 297/427: Change compiler flag order (work around old gcc bug)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d21cc86540 188/427: Add lexical binding to tests., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3d556608ef 394/427: emacsql-mysql: Abort if mysql cannot be found, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 568e663032 193/427: Fold dashes into underscores in identifiers., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c85ab1f7b4 194/427: Enable foreign keys in SQLite by default., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f51bb4bfaf 195/427: Allow foreign key specifications within columns., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c4abd187a3 196/427: Remove junk file., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3dfd0d4b8c 199/427: Fix missing argument typo., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 7341144e49 201/427: Fix ordering bug in emacsql--var-vars., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d8d4bf4b98 202/427: Add emacsql-with-transaction macro., ELPA Syncer, 2022/12/13