(fix)db: prevent empty aliases sql expression (#1813)

This commit is contained in:
Jethro Kuan
2021-08-27 19:01:43 +08:00
committed by GitHub
parent 714ea7a3fc
commit ab87a08e17
2 changed files with 7 additions and 4 deletions

View File

@ -9,6 +9,7 @@
### Fixed
- [#1798](https://github.com/org-roam/org-roam/pull/1798) org-roam-node-at-point: do not skip invisible headings
- [#1807](https://github.com/org-roam/org-roam/pull/1807) capture: always trigger `:if-new` template for existing nodes
- [#1813](https://github.com/org-roam/org-roam/pull/1813) db: prevent empty ROAM_ALIASES from crashing db updates
## 2.1.0
### Added

View File

@ -310,6 +310,7 @@ If UPDATE-P is non-nil, first remove the file in the database."
(deadline nil)
(level 0)
(aliases (org-entry-get (point) "ROAM_ALIASES"))
(aliases (when aliases (split-string-and-unquote aliases)))
(tags org-file-tags)
(refs (org-entry-get (point) "ROAM_REFS"))
(properties (org-entry-properties))
@ -336,7 +337,7 @@ If UPDATE-P is non-nil, first remove the file in the database."
:values $v1]
(mapcar (lambda (alias)
(vector id alias))
(split-string-and-unquote aliases))))
aliases)))
(when refs
(setq refs (split-string-and-unquote refs))
(let (rows)
@ -386,13 +387,14 @@ If UPDATE-P is non-nil, first remove the file in the database."
(defun org-roam-db-insert-aliases ()
"Insert aliases for node at point into Org-roam cache."
(when-let ((node-id (org-id-get))
(aliases (org-entry-get (point) "ROAM_ALIASES")))
(when-let* ((node-id (org-id-get))
(aliases (org-entry-get (point) "ROAM_ALIASES"))
(aliases (split-string-and-unquote aliases)))
(org-roam-db-query [:insert :into aliases
:values $v1]
(mapcar (lambda (alias)
(vector node-id alias))
(split-string-and-unquote aliases)))))
aliases))))
(defun org-roam-db-insert-tags ()
"Insert tags for node at point into Org-roam cache."