emacs-elpa-diffs
[Top][All Lists]
Advanced

[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 "



reply via email to

[Prev in Thread] Current Thread [Next in Thread]