branch: elpa/emacsql
commit 1ad58cd68dc47f7deb118b57aa78a1b75ace60c5
Author: Christopher Wellons <well...@nullprogram.com>
Commit: Christopher Wellons <well...@nullprogram.com>

    Allow substatement in IN operator.
---
 emacsql.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/emacsql.el b/emacsql.el
index 401dc74506..e946a29422 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -466,9 +466,14 @@ definitions for return from a `emacsql-defexpander'."
                (2 (format "%s - %s" (recur 0) (recur 1)))))
             ;; IN special case
             ((in)
-             (if (= 2 (length args))
-                 (format "%s IN %s" (recur 0)
-                         (var (nth 1 args) :vector))))))))))
+             (cl-case (length args)
+               (1 (error "Wrong number of operands for %s" op))
+               (2 (format "%s IN %s" (recur 0) (var (nth 1 args) :vector)))
+               (otherwise
+                (let ((subsql (cl-coerce (cdr args) 'vector)))
+                  (format "%s IN %s"
+                          (recur 0)
+                          (combine (emacsql-expand subsql :sub)))))))))))))
 
 ;; SQL Expansion Functions:
 

Reply via email to