branch: elpa/emacsql commit cefe1ec01426231bdb79e154f5301f1500ed68b1 Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@nullprogram.com>
Add emacsql-sqlite3-unavailable-p. --- README.md | 2 +- emacsql-tests.el | 1 + emacsql.el | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 320333fe43..9675a6fdca 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Emacsql, including numbers, strings, symbols, lists, vectors, and closures. Emacsql has no concept of "TEXT" values; it's all just lisp objects. -Requires Emacs 24 or later. +Requires Emacs 24 or later and SQLite 3.7.15 or later. Due to [bad behavior from SQLite on Windows][stderr] Emacsql will *not* signal error messages for invalid statements on this platform. diff --git a/emacsql-tests.el b/emacsql-tests.el index 2138d3ec96..5744e3c3a2 100644 --- a/emacsql-tests.el +++ b/emacsql-tests.el @@ -75,6 +75,7 @@ "CREATE TEMPORARY TABLE IF NOT EXISTS x (y);")) (ert-deftest emacsql-system () + (should-not (emacsql-sqlite3-unavailable-p)) (emacsql-with-connection (db nil) (emacsql db [:create-table foo [x]]) (should-error (emacsql db [:create-table foo [x]])) diff --git a/emacsql.el b/emacsql.el index 70cf4e673c..20b04eb632 100644 --- a/emacsql.el +++ b/emacsql.el @@ -99,6 +99,24 @@ This collection exists for cleanup purposes.") do (accept-process-output))) (emacsql--clear conn)) +(defun emacsql-sqlite3-unavailable-p () + "Return a reason if the sqlite3 executable is not available. + +:no-executable -- cannot find the executable +:cannot-execute -- cannot run the executable +:old-version -- sqlite3 version is too old" + (let ((sqlite3 emacsql-sqlite3-executable)) + (if (null (executable-find sqlite3)) + :no-executable + (condition-case _ + (with-temp-buffer + (call-process sqlite3 nil (current-buffer) nil "--version") + (let ((version (car (split-string (buffer-string))))) + (if (version< version "3.7.15") + :old-version + nil))) + (error :cannot-execute))))) + (cl-defun emacsql-connect (file &key log) "Open a connected to database stored in FILE. If FILE is nil use an in-memory database.