(fix)db: prevent invalid refs from crashing db update (#1816)

Previously when ROAM_REFS is non-empty, but the refs are invalid, this
will cause an empty SQL expression and crash the db caching. This fixes
that scenario.
This commit is contained in:
Jethro Kuan
2021-08-28 13:42:30 +08:00
committed by GitHub
parent cfabe0ec38
commit 0e6b93a253
2 changed files with 5 additions and 3 deletions

View File

@ -11,6 +11,7 @@
- [#1798](https://github.com/org-roam/org-roam/pull/1798) org-roam-node-at-point: do not skip invisible headings - [#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 - [#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 - [#1813](https://github.com/org-roam/org-roam/pull/1813) db: prevent empty ROAM_ALIASES from crashing db updates
- [#1816](https://github.com/org-roam/org-roam/pull/1816) db: prevent invalid ROAM_REFS from crashing db updates
## 2.1.0 ## 2.1.0
### Added ### Added

View File

@ -418,9 +418,10 @@ If UPDATE-P is non-nil, first remove the file in the database."
(push (vector node-id (match-string 2 ref) (match-string 1 ref)) rows)) (push (vector node-id (match-string 2 ref) (match-string 1 ref)) rows))
(lwarn '(org-roam) :warning (lwarn '(org-roam) :warning
"%s:%s\tInvalid ref %s, skipping..." (buffer-file-name) (point) ref)))) "%s:%s\tInvalid ref %s, skipping..." (buffer-file-name) (point) ref))))
(org-roam-db-query [:insert :into refs (when rows
:values $v1] (org-roam-db-query [:insert :into refs
rows)))) :values $v1]
rows)))))
(defun org-roam-db-insert-link (link) (defun org-roam-db-insert-link (link)
"Insert link data for LINK at current point into the Org-roam cache." "Insert link data for LINK at current point into the Org-roam cache."