branch: elpa/emacsql commit 77ae713186a750bc5c6fb1e77aa177f445dfe0c2 Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@nullprogram.com>
Create table expander. --- emacsql-tests.el | 4 +++- emacsql.el | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/emacsql-tests.el b/emacsql-tests.el index 59332dbe34..f27fd23860 100644 --- a/emacsql-tests.el +++ b/emacsql-tests.el @@ -48,4 +48,6 @@ (emacsql-tests-query [:select * :from employees] () "SELECT * FROM employees;") (emacsql-tests-query [:select * :from employees :where (< salary 50000)] () - "SELECT * FROM employees WHERE salary < 50000;")) + "SELECT * FROM employees WHERE salary < 50000;") + (emacsql-tests-query [:create-table foo [a b c]] () + "CREATE TABLE foo (a, b, c);")) diff --git a/emacsql.el b/emacsql.el index cbf2634fb6..be59bc2977 100644 --- a/emacsql.el +++ b/emacsql.el @@ -411,6 +411,11 @@ definitions for return from a `emacsql-defexpander'." (cl-destructuring-bind (op a b) expr (format "%s %s %s" (var a :auto) op (var b :auto))))) +(emacsql-defexpander :create-table (table schema) + (emacsql-with-vars "CREATE TABLE " + (format "%s (%s)" (var table :identifier) + (emacsql--schema-to-string schema)))) + (provide 'emacsql) ;;; emacsql.el ends here