fix: db lint

Also silence noisy successful db test which distracts from actual
failing tests
This commit is contained in:
Gabriel Horner
2026-02-26 12:21:54 -05:00
parent bcacfd39f5
commit 5b1bfeed2b
3 changed files with 22 additions and 8 deletions

View File

@@ -678,6 +678,12 @@
db
v))
(defn- add-entity
[acc class-id entity]
(if class-id
(update acc class-id (fnil conj #{}) entity)
acc))
(defn get-bidirectional-properties
"Given a target entity id, returns a seq of maps with:
* :class - class entity
@@ -685,12 +691,7 @@
* :entities - node entities that reference the target via ref properties"
[db target-id]
(when (and db target-id (d/entity db target-id))
(let [add-entity
(fn [acc class-id entity]
(if class-id
(update acc class-id (fnil conj #{}) entity)
acc))
*attr->bidirectional? (volatile! {})
(let [*attr->bidirectional? (volatile! {})
bidirectional-property-attr-cached?
(fn [attr]
(let [cache @*attr->bidirectional?]

View File

@@ -92,3 +92,14 @@
_ (when (::sqlite-export/graph-files export-map)
(d/transact! conn (::sqlite-export/graph-files export-map)))]
conn))
(defmacro silence-stderr
"Silence stderr as successful tests should print long stderr messages"
[& body]
`(let [orig-write# (.-write js/process.stderr)]
(set! (.-write js/process.stderr)
(fn [& _] true))
(try
~@body
(finally
(set! (.-write js/process.stderr) orig-write#)))))

View File

@@ -100,8 +100,10 @@
(let [conn (db-test/create-conn)]
(testing "#Task shouldn't be converted to property"
(is (thrown? js/Error
(with-out-str (ldb/transact! conn [{:db/ident :logseq.class/Task
:block/tags :logseq.class/Property}])))))
(with-out-str
(db-test/silence-stderr
(ldb/transact! conn [{:db/ident :logseq.class/Task
:block/tags :logseq.class/Property}]))))))
(ldb/transact-with-temp-conn!
conn
{}