(db): support emacsql-sqlite-{builtin,module} (#2158)

* (db): support emacsql-sqlite-{builtin,module}

Add support for emacsql-sqlite-builtin and emacs-sqlite-module. Fixes #2146.

* update changelog
This commit is contained in:
Jethro Kuan
2022-04-16 14:16:39 -07:00
committed by GitHub
parent 9eaf91b801
commit 8318da895d
2 changed files with 39 additions and 16 deletions

View File

@ -3,6 +3,7 @@
### Breaking ### Breaking
### Added ### Added
- [#2138](https://github.com/org-roam/org-roam/pull/2138) export: add new module - [#2138](https://github.com/org-roam/org-roam/pull/2138) export: add new module
- [#2158](https://github.com/org-roam/org-roam/pull/2158) db: support emacsql-sqlite-builtin and emacsql-sqlite-module
### Removed ### Removed
### Fixed ### Fixed

View File

@ -36,23 +36,35 @@
;;; Options ;;; Options
(defcustom org-roam-database-connector 'sqlite (defcustom org-roam-database-connector 'sqlite
"The database connector used by Org-roam. "The database connector used by Org-roam.
This must be set before `org-roam' is loaded. To use an This must be set before `org-roam' is loaded. To use an alternative
alternative connector you must install the respective package connector you must install the respective package explicitly.
explicitly. When `sqlite', then use the `emacsql-sqlite' library The default is `sqlite', which uses the `emacsql-sqlite' library
that is being maintained in the same repository as `emacsql' that is being maintained in the same repository as `emacsql'
itself. When `libsqlite3', then use the `emacsql-libsqlite3' itself.
library, which itself uses a module provided by the `sqlite3' If you are using Emacs 29, then the recommended connector is
package. This is still experimental. When `sqlite3', then use the `sqlite-builtin', which uses the new builtin support for SQLite.
`emacsql-sqlite3' library, which uses the official `sqlite3' cli You need to install the `emacsql-sqlite-builtin' package to use
tool, which is not recommended because it is not suitable to be this connector.
used like this, but has the advantage that you likely don't need If you are using an older Emacs release, then the recommended
a compiler. See https://nullprogram.com/blog/2014/02/06/." connector is `sqlite-module', which uses the module provided by
:package-version '(org-roam . "2.2.0") the `sqlite3' package. This is very similar to the previous
:group 'org-roam connector and the built-in support in Emacs 29 derives from this
module. You need to install the `emacsql-sqlite-module' package
to use this connector.
For the time being `libsqlite3' is still supported. Do not use
this, it is an older version of the `sqlite-module' connector
from before the connector and the package were renamed.
For the time being `sqlite3' is also supported. Do not use this.
This uses the third-party `emacsql-sqlite3' package, which uses
the official `sqlite3' cli tool, which is not intended
to be used like this. See https://nullprogram.com/blog/2014/02/06/."
:package-version '(forge . "0.3.0")
:group 'forge
:type '(choice (const sqlite) :type '(choice (const sqlite)
(const libsqlite3) (const sqlite-builtin)
(const sqlite3) (const sqlite-module)
(symbol :tag "other"))) (const :tag "libsqlite3 (OBSOLETE)" libsqlite3)
(const :tag "sqlite3 (BROKEN)" sqlite3)))
(defcustom org-roam-db-location (locate-user-emacs-file "org-roam.db") (defcustom org-roam-db-location (locate-user-emacs-file "org-roam.db")
"The path to file where the Org-roam database is stored. "The path to file where the Org-roam database is stored.
@ -137,8 +149,10 @@ ROAM_REFS."
org-roam-db--connection)) org-roam-db--connection))
(declare-function emacsql-sqlite "ext:emacsql-sqlite") (declare-function emacsql-sqlite "ext:emacsql-sqlite")
(declare-function emacsql-libsqlite3 "ext:emacsql-libsqlite3")
(declare-function emacsql-sqlite3 "ext:emacsql-sqlite3") (declare-function emacsql-sqlite3 "ext:emacsql-sqlite3")
(declare-function emacsql-libsqlite3 "ext:emacsql-libsqlite3")
(declare-function emacsql-sqlite-builtin "ext:emacsql-sqlite-builtin")
(declare-function emacsql-sqlite-module "ext:emacsql-sqlite-module")
(defun org-roam-db--conn-fn () (defun org-roam-db--conn-fn ()
"Return the function for creating the database connection." "Return the function for creating the database connection."
@ -147,6 +161,14 @@ ROAM_REFS."
(progn (progn
(require 'emacsql-sqlite) (require 'emacsql-sqlite)
#'emacsql-sqlite)) #'emacsql-sqlite))
(sqlite-builtin
(progn
(require 'emacs-sqlite-builtin)
#'emacsql-sqlite-builtin))
(sqlite-module
(progn
(require 'emacs-sqlite-module)
#'emacsql-sqlite-module))
(libsqlite3 (libsqlite3
(progn (progn
(require 'emacsql-libsqlite3) (require 'emacsql-libsqlite3)