branch: elpa/emacsql commit 54c180017e21a8e441480c915c8b44fd997b254a Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@nullprogram.com>
Add :pragma and note in README. --- README.md | 17 +++++++++++++++-- emacsql.el | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e58c86ce2b..8c554d7a9b 100644 --- a/README.md +++ b/README.md @@ -93,8 +93,13 @@ the details on what each of these means. :foreign (subjectid subject id :on-delete :cascade)) ``` -Put the keys in a vector if the reference is composite, but remember -that the cardinality must match. +Put the keys in a vector if the reference is composite. Also remember +that foreign key checks are currently disabled by default in SQLite, +so you'll need to enable it for each connection. + +```el +(emacsql db [:pragma (= foreign_keys on)]) +``` ## Operators @@ -271,6 +276,14 @@ Provides `UNION`, `UNION ALL`, `DIFFERENCE`, and `EXCEPT`. [:select * :from sales :union :select * :from accounting] ``` +#### :pragma `<expr>` + +Provides `PRAGMA`. + +```el +(emacsql db [:pragma (= foreign_keys on)]) +``` + ### Templates To make statement compilation faster, and to avoid making you build up diff --git a/emacsql.el b/emacsql.el index 6e44c2a2bd..158a23e439 100644 --- a/emacsql.el +++ b/emacsql.el @@ -678,6 +678,10 @@ definitions for return from a `emacsql-defexpander'." (emacsql-defexpander :except () (list "EXCEPT")) +(emacsql-defexpander :pragma (expr) + (emacsql-with-vars "PRAGMA " + (expr expr))) + (provide 'emacsql) ;;; emacsql.el ends here