branch: elpa/emacsql commit 2faed63b20eff4a4cbc78c080856979909979ba0 Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@nullprogram.com>
Prime emacsql-expand for substatements. --- emacsql.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/emacsql.el b/emacsql.el index 8c14f9f392..401dc74506 100644 --- a/emacsql.el +++ b/emacsql.el @@ -311,7 +311,7 @@ a list of (<string> [arg-pos] ...)." (declare (indent 2)) `(emacsql-add-expander ,keyword ,(length args) (lambda ,args ,@body))) -(defun emacsql-expand (sql) +(defun emacsql-expand (sql &optional subsql-p) "Expand SQL into a SQL-consumable string, with variables." (let* ((cache emacsql-expander-cache) (cached (and cache (gethash sql cache)))) @@ -325,7 +325,9 @@ a list of (<string> [arg-pos] ...)." else do (error "Unrecognized keyword %s" keyword) do (setf items (cl-subseq items arity)) finally - (let ((string (concat (mapconcat #'car parts " ") ";")) + (let ((string (concat (if subsql-p "(" "") + (mapconcat #'car parts " ") + (if subsql-p ")" ";"))) (vars (apply #'nconc (mapcar #'cdr parts)))) (cl-return (setf (gethash sql cache) (cons string vars))))))))