(fix)db: pragma foreign keys to work with sqlite3 (#2018)
* (fix):db: pragma foreign keys to work with sqlite3 This commit is follow-up for PR #2009 should fix issues #1927 & #1910. Currently, `[:pragma (= foreign_keys ON)]` is present only in function `org-roam-db--init`. This means the `foreign_keys` is turned on only when the db file is created for the first time. Subsequent Emacs sessions won't turn it on as the db file is already present and does not evaluate `org-roam-db--init`. This PRAGMA needs to be turned on each database connection at runtime according to sqlite's documentation (https://sqlite.org/foreignkeys.html#fk_enable) ``` Foreign key constraints are disabled by default (for backwards compatibility), so must be enabled separately for each database connection ``` I have observed that on Windows only the Emacs session that initially creates the Org-roam db file works correctly with the `sqlite3` option. Subsequent Emacs sessions have the same "Unique constraint failed" error messages. I have tested this patch on Windows and Ubuntu; both seem to work in the first and subsequent Emacs sessions. I am not 100% sure if the location of the PRAGMA is the best; use it as a proof-of-cocenpt for the fix. Thank you. * remove: [:pragma (= foreign_keys ON)] from org-roam-db--init * fix: defconst org-roam--sqlite-available-p outputs error When `org-roam-database-connector` is not `sqlite`, it outputs an unnecessary error when Org-roam starts up as `defconst` evaluates `(emacsql-sqlite-ensure-binary)`. ``` Org-roam initialization: (error "No EmacSQL SQLite binary available, aborting") ``` For other database connectors, this is not relevant. * chore: rm org-roam--sqlite-available-p As per our conversation, org-roam--sqlite-available-p not needed.master
parent
ee9a8d423e
commit
679ef6ef00
1 changed files with 1 additions and 7 deletions
Loading…
Reference in new issue