branch: elpa/emacsql commit 1e9857ccc450cf339ea6dd4b144e57e219c3be9b Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@nullprogram.com>
Allow variables inside vectors. --- emacsql.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/emacsql.el b/emacsql.el index 4e3875a12b..6f7596648b 100644 --- a/emacsql.el +++ b/emacsql.el @@ -413,6 +413,17 @@ definitions for return from a `emacsql-defexpander'." (declare-function combine nil (expanded)) (declare-function var nil (thing kind)) +(defun emacsql--vector (vector) + "Expand VECTOR, making variables as needed." + (emacsql-with-vars "" + (cl-etypecase vector + (symbol + (var vector :vector)) + (list + (mapconcat (lambda (v) (combine (emacsql--vector v))) vector ", ")) + (vector + (format "(%s)" (mapconcat (lambda (x) (var x :value)) vector ", ")))))) + (defun emacsql--expr (expr) "Expand EXPR recursively." (emacsql-with-vars "" @@ -498,7 +509,7 @@ definitions for return from a `emacsql-defexpander'." (emacsql-defexpander :values (values) (emacsql-with-vars "VALUES " - (var values :vector))) + (combine (emacsql--vector values)))) (emacsql-defexpander :update (table) (emacsql-with-vars "UPDATE "