[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql ad24b1c508 208/427: Add JOIN syntax.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql ad24b1c508 208/427: Add JOIN syntax. |
Date: |
Tue, 13 Dec 2022 02:59:42 -0500 (EST) |
branch: elpa/emacsql
commit ad24b1c5087a3f2682d64376624eae911c4e05f5
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add JOIN syntax.
---
README.md | 36 ++++++++++++++++++++++++++++++++++++
emacsql-compiler.el | 37 +++++++++++++++++++++++++++++++++++--
2 files changed, 71 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 5dfd89765f..a8c8ae6bd8 100644
--- a/README.md
+++ b/README.md
@@ -215,6 +215,42 @@ Provides `FROM`.
[... :from [(as (:select ...) s1) (as (:select ...) s2)]]
```
+#### :join `<table>`
+
+Provides `JOIN`.
+
+```el
+[... :join players ...]
+[... :join (as players p) ...]
+```
+
+#### :outer, :inner, :cross, :natural, :left, :right, :full
+
+Provides `OUTER`, `INNER`, `CROSS`, `NATURAL`, `LEFT`, `RIGHT`, and
+`FULL`.
+
+```el
+[... :natural :join ...]
+[... :left :outer :join ...]
+```
+
+#### :on `<expr>`
+
+Provides `ON`.
+
+```el
+[... :on (= entry-id other-id)]
+```
+
+#### :using `<column>|[<columns>]`
+
+Provides `USING`.
+
+```el
+[... :using entry-id]
+[... :using [entry-id, feed-id]]
+```
+
#### :where `<expr>`, :having `<expr>`
Provides `WHERE` and `HAVING`.
diff --git a/emacsql-compiler.el b/emacsql-compiler.el
index 5413d5cee9..982e435922 100644
--- a/emacsql-compiler.el
+++ b/emacsql-compiler.el
@@ -407,12 +407,45 @@ definitions for return from a `emacsql-defexpander'."
(emacsql-with-vars "FROM "
(idents sources)))
-(emacsql-defexpander :replace ()
- (list "REPLACE"))
+(emacsql-defexpander :join (source)
+ (emacsql-with-vars "JOIN "
+ (idents source)))
+
+(emacsql-defexpander :natural ()
+ (list "NATURAL"))
+
+(emacsql-defexpander :outer ()
+ (list "OUTER"))
+
+(emacsql-defexpander :inner ()
+ (list "INNER"))
+
+(emacsql-defexpander :cross ()
+ (list "CROSS"))
+
+(emacsql-defexpander :left ()
+ (list "LEFT"))
+
+(emacsql-defexpander :right ()
+ (list "RIGHT"))
+
+(emacsql-defexpander :full ()
+ (list "FULL"))
+
+(emacsql-defexpander :on (expr)
+ (emacsql-with-vars "ON "
+ (expr expr)))
+
+(emacsql-defexpander :using (columns)
+ (emacsql-with-vars "USING "
+ (format "(%s)" (idents columns))))
(emacsql-defexpander :insert ()
(list "INSERT"))
+(emacsql-defexpander :replace ()
+ (list "REPLACE"))
+
(emacsql-defexpander :into (table)
"Expands to the INTO keywords."
(emacsql-with-vars "INTO "
- [nongnu] elpa/emacsql c85ab1f7b4 194/427: Enable foreign keys in SQLite by default., (continued)
- [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
- [nongnu] elpa/emacsql dc178532e5 203/427: Add emacsql-with-bind., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql cc92c154ee 205/427: Disallow nil as an identifier., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 75c0c4aeb7 204/427: Tweak emacsql-with-bind macro., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3f38b357c3 206/427: Detect empty SQL vectors (better error messages)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ad24b1c508 208/427: Add JOIN syntax.,
ELPA Syncer <=
- [nongnu] elpa/emacsql fe2eef212c 210/427: Fix header typo., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 89654ad76b 211/427: Add identifier note., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 543189295d 215/427: Drop the pointless autoloads., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3127283cd1 218/427: Clean up middleware a bit., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql cf16cdb2f8 217/427: Add a special characters test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 2db4a84598 225/427: Allow os tuples to be specified as an env var., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ba2fac7701 228/427: Update the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql af2cdddca1 231/427: Squash a bunch of bugs., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d3fa5b908f 234/427: Add funcall operator., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b29ea275d4 236/427: Tweak limitations notes., ELPA Syncer, 2022/12/13