fix: ref checks in schema

attribute in the wrong schema and db graph only vars had file graph
keys. Also temp fix to avoid crashing ui with props
pull/11177/head
Gabriel Horner 2024-04-12 12:15:59 -04:00
parent b2a22498ea
commit 4f3b7e7687
4 changed files with 10 additions and 13 deletions

View File

@ -4,7 +4,6 @@
(:require [logseq.db.sqlite.db :as sqlite-db]
[logseq.db.frontend.malli-schema :as db-malli-schema]
[logseq.db.frontend.validate :as db-validate]
[logseq.db.frontend.property :as db-property]
[datascript.core :as d]
[clojure.string :as string]
[nbb.core :as nbb]

View File

@ -134,7 +134,6 @@
[:block/updated-at :int]
[:block/format [:enum :markdown]]
[:block/properties {:optional true} [:set :int]]
[:property/pair-property {:optional true} :int]
[:block/refs {:optional true} [:set :int]]
[:block/tags {:optional true} [:set :int]]
[:block/collapsed-properties {:optional true} [:set :int]]
@ -428,7 +427,7 @@
(string/join ", " undeclared-ref-attrs))
{}))))
(let [malli-one-ref-attrs (->> (concat class-attrs page-attrs block-attrs page-or-block-attrs (rest normal-page))
(let [malli-one-ref-attrs (->> (concat class-attrs page-attrs block-attrs page-or-block-attrs (rest normal-page) (rest property-pair))
(filter #(= (last %) :int))
(map first)
set)

View File

@ -267,7 +267,9 @@
(when db
(let [block (or (d/entity db (:db/id block)) block)
;; FIXME: Use db-based-graph? when this fn moves to another ns
properties' (if (string/starts-with? repo "logseq_db_")
properties' (if (and (string/starts-with? repo "logseq_db_")
;; FIXME: Find a way to do this nbb check without affecting frontend
(not (:block/raw-properties block)))
(properties block)
(:block/properties block))]
(lookup repo properties' db-ident))))

View File

@ -139,8 +139,7 @@
:asset/meta {}}))
(def retract-attributes
#{
:block/refs
#{:block/refs
:block/tags
:block/alias
:block/marker
@ -154,9 +153,7 @@
:block/properties-text-values
:block/macros
:block/invalid-properties
:block/warning
}
)
:block/warning})
;; If only block/content changes
(def db-version-retract-attributes
@ -181,21 +178,21 @@
:block/tags})
;; DB graph helpers
;; ================
(def ref-type-attributes
(into #{}
(keep (fn [[attr-name attr-body-map]]
(when (= :db.type/ref (:db/valueType attr-body-map))
attr-name)))
(merge schema
schema-for-db-based-graph)))
schema-for-db-based-graph))
(def card-many-attributes
(into #{}
(keep (fn [[attr-name attr-body-map]]
(when (= :db.cardinality/many (:db/cardinality attr-body-map))
attr-name)))
(merge schema
schema-for-db-based-graph)))
schema-for-db-based-graph))
(def card-many-ref-type-attributes
(set/intersection card-many-attributes ref-type-attributes))