Explorar o código

Merge branch 'refactor/db-properties-schema' into refactor/db-remove-block-name-unique

Tienson Qin hai 1 ano
pai
achega
b9195e40e5

+ 9 - 18
deps/db/src/logseq/db/frontend/malli_schema.cljs

@@ -10,35 +10,26 @@
 ;; :db/ident malli schemas
 ;; =======================
 
-(def logseq-property-namespaces
-  #{"logseq.property" "logseq.property.table" "logseq.property.tldraw"
-    "logseq.task"})
-
-(def db-attribute-properties
-  "Internal properties that are also db attributes"
-  #{:block/alias :block/tags})
-
 (def db-attribute-ident
-  (into [:enum] db-attribute-properties))
+  (into [:enum] db-property/db-attribute-properties))
 
 (def logseq-property-ident
   [:and :keyword [:fn
                   {:error/message "should be a valid logseq property namespace"}
-                  (fn logseq-namespace? [k]
-                    (contains? logseq-property-namespaces (namespace k)))]])
+                  db-property/logseq-property?]])
 
 (def internal-property-ident
   [:or logseq-property-ident db-attribute-ident])
 
-(defn user-property-namespace?
+(defn- user-property?
   "Determines if keyword is a user property"
   [kw]
-  (contains? #{"user.property"} (namespace kw)))
+  (contains? db-property/user-property-namespaces (namespace kw)))
 
 (def user-property-ident
   [:and :keyword [:fn
                   {:error/message "should be a valid user property namespace"}
-                  user-property-namespace?]])
+                  user-property?]])
 
 (def property-ident
   [:or internal-property-ident user-property-ident])
@@ -48,7 +39,7 @@
   db-attribute-ident. It's important to grow this list purposefully and have it
   start with 'logseq' to allow for users and 3rd party plugins to provide their
   own namespaces to core concepts."
-  (into logseq-property-namespaces #{"logseq.class" "logseq.kv"}))
+  (into db-property/logseq-property-namespaces #{"logseq.class" "logseq.kv"}))
 
 (def logseq-ident
   [:and :keyword [:fn
@@ -246,8 +237,8 @@
 
 (def property-page
   [:multi {:dispatch (fn [m]
-                       (or (contains? logseq-property-namespaces (namespace (m :db/ident)))
-                           (contains? db-attribute-properties (m :db/ident))))}
+                       (or (db-property/logseq-property? (m :db/ident))
+                           (contains? db-property/db-attribute-properties (m :db/ident))))}
    [true internal-property]
    [:malli.core/default user-property]])
 
@@ -357,7 +348,7 @@
 
 (def property-value-placeholder
   [:map
-   [:db/ident [:= :property/empty-placeholder]]])
+   [:db/ident [:= :logseq.property/empty-placeholder]]])
 
 (def DB
   "Malli schema for entities from schema/schema-for-db-based-graph. In order to

+ 60 - 31
deps/db/src/logseq/db/frontend/property.cljs

@@ -1,9 +1,11 @@
 (ns logseq.db.frontend.property
   "Property related fns for DB graphs and frontend/datascript usage"
-  (:require [logseq.db.sqlite.util :as sqlite-util]
-            [datascript.core :as d]
+  (:require [datascript.core :as d]
             [clojure.string :as string]))
 
+;; Main property vars
+;; ==================
+
 (def ^:large-vars/data-var built-in-properties*
   "Map of built in properties for db graphs with their :db/ident as keys.
    Each property has a config map with the following keys:
@@ -19,8 +21,7 @@
    * :name - Property's :block/name as a keyword. If none given, one is derived from the db/ident
    * :attribute - Property keyword that is saved to a datascript attribute outside of :block/properties
    * :closed-values - Vec of closed-value maps for properties with choices. Map
-     has keys :value, :db-ident, :uuid and :icon
-   * :db-ident - Keyword to set :db/ident and give property unique id in db"
+     has keys :value, :db-ident, :uuid and :icon"
   {:block/alias           {:original-name "Alias"
                            :attribute :block/alias
                            :schema {:type :page
@@ -179,6 +180,47 @@
                  (assoc v :name (keyword (string/lower-case (name k)))))]))
        (into {})))
 
+(def db-attribute-properties
+  "Internal properties that are also db schema attributes"
+  #{:block/alias :block/tags})
+
+(assert (= db-attribute-properties
+           (set (keep (fn [[k {:keys [attribute]}]] (when attribute k))
+                      built-in-properties)))
+        "All db attribute properties are configured in built-in-properties")
+
+(def logseq-property-namespaces
+  #{"logseq.property" "logseq.property.table" "logseq.property.tldraw"
+    "logseq.task"})
+
+(defn logseq-property?
+  "Determines if keyword is a logseq property"
+  [kw]
+  (contains? logseq-property-namespaces (namespace kw)))
+
+(def user-property-namespaces
+  #{"user.property"})
+
+(defn property?
+  "Determines if ident kw is a property"
+  [k]
+  (let [k-name (namespace k)]
+    (and k-name
+         (or (contains? logseq-property-namespaces k-name)
+             (contains? user-property-namespaces k-name)
+             (and (keyword? k) (contains? #{:block/tags :block/alias} k))))))
+
+;; Helper fns
+;; ==========
+
+(defn properties
+  "Fetch all properties of entity like :block/properties used to do.
+   Use this in deps because nbb can't use :block/properties from entity-plus"
+  [e]
+  (->> (into {} e)
+       (filter (fn [[k _]] (property? k)))
+       (into {})))
+
 (defn valid-property-name?
   [s]
   {:pre [(string? s)]}
@@ -186,11 +228,11 @@
   (not (re-find #"^(#|\[\[)" s)))
 
 (defn get-pid
-  "Get a built-in property's id (keyword name for file graph and uuid for db graph)
-  given its db-ident. Use this fn on a file or db graph. Use
-  db-pu/get-built-in-property-uuid if only in a db graph context"
+  "Get a built-in property's id (keyword name for file graph and db-ident for db
+  graph) given its db-ident. No need to use this fn in a db graph only context"
   [repo db-ident]
-  (if (sqlite-util/db-based-graph? repo)
+  ;; FIXME: Use db-based-graph? when this fn moves to another ns
+  (if (string/starts-with? repo "logseq_db_")
     db-ident
     (get-in built-in-properties [db-ident :name])))
 
@@ -203,9 +245,12 @@
   "Get the value of built-in block's property by its db-ident"
   [repo db block db-ident]
   (when db
-    (let [block (or (d/entity db (:db/id block)) block)]
-      (when-let [properties (:block/properties block)]
-        (lookup repo properties db-ident)))))
+    (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 block)
+                        (:block/properties block))]
+      (lookup repo properties' db-ident))))
 
 (defn shape-block?
   [repo db block]
@@ -231,25 +276,9 @@
               (when (= (closed-value-name e) value-name)
                 e))) values)))
 
-(defn property?
-  [k]
-  (let [k-name (namespace k)]
-    (and k-name
-         (or (string/starts-with? k-name "logseq.property")
-             (string/starts-with? k-name "logseq.task")
-             (string/starts-with? k-name "user.property")
-             (and (keyword? k) (contains? #{:block/tags :block/alias} k))))))
-
-(defn properties
-  "Fetch all properties of entity like :block/properties used to do.
-   Use this in deps because nbb can't use :block/properties from entity-plus"
-  [e]
-  (->> (into {} e)
-       (filter (fn [[k _]] (property? k)))
-       (into {})))
-
 ;; TODO: db ident should obey clojure's rules for keywords
-(defn get-db-ident-from-name
+(defn user-property-ident-from-name
+  "Makes a user property :db/ident from a name by sanitizing the given name"
   [property-name]
   (let [n (-> (string/lower-case property-name)
               (string/replace #"^:\s*" "")
@@ -257,8 +286,8 @@
               (string/replace " " "-")
               (string/replace "#" "")
               (string/trim))]
-    (when-not (string/blank? n)
-      (keyword "user.property" n))))
+    (assert (seq n) "name is not empty")
+    (keyword "user.property" n)))
 
 (defn get-class-ordered-properties
   [class-entity]

+ 1 - 1
deps/db/src/logseq/db/frontend/property/util.cljs

@@ -63,7 +63,7 @@
                (:closed-values property)))
         property-schema (assoc (:block/schema property)
                                :values (mapv :block/uuid closed-value-blocks-tx))
-        property-tx (merge (sqlite-util/build-new-property db-ident prop-name property-schema)
+        property-tx (merge (sqlite-util/build-new-property db-ident property-schema {:original-name prop-name})
                            property-attributes)]
     (into [property-tx page-tx]
           (when-not closed-value-page-uuids? closed-value-blocks-tx))))

+ 1 - 0
deps/db/src/logseq/db/sqlite/common_db.cljs

@@ -167,6 +167,7 @@
                     (remove (fn [[k _v]]
                               (or (integer? k)
                                   (and (keyword? k)
+                                       ;; filters out all logseq-ident-namespaces
                                        (string/starts-with? (namespace k) "logseq.")))))
                     (into {}))
         idents (remove nil?

+ 4 - 4
deps/db/src/logseq/db/sqlite/create_graph.cljs

@@ -28,8 +28,8 @@
                        {})
                       [(sqlite-util/build-new-property
                         db-ident
-                        prop-name
-                        schema)])]
+                        schema
+                        {:original-name prop-name})])]
          (update blocks 0 default-db/mark-block-as-built-in)))
      built-in-properties)))
 
@@ -48,8 +48,8 @@
   [config-content]
   (let [initial-data [(kv :db/type "db")
                       (kv :schema/version db-schema/version)
-                      ;; empty property value
-                      {:db/ident :property/empty-placeholder}]
+                      ;; Empty property value used by db.type/ref properties
+                      {:db/ident :logseq.property/empty-placeholder}]
         initial-files [{:block/uuid (d/squuid)
                         :file/path (str "logseq/" "config.edn")
                         :file/content config-content

+ 28 - 27
deps/db/src/logseq/db/sqlite/util.cljs

@@ -7,7 +7,8 @@
             [datascript.transit :as dt]
             [datascript.impl.entity :as de]
             [datascript.core :as d]
-            [cljs-bean.transit]))
+            [cljs-bean.transit]
+            [logseq.db.frontend.property :as db-property]))
 
 (defonce db-version-prefix "logseq_db_")
 (defonce file-version-prefix "logseq_local_")
@@ -67,32 +68,32 @@
 (def property-ref-types #{:page :block :date :entity})
 
 (defn build-new-property
-  "Build a standard new property so that it is is consistent across contexts"
-  [db-ident prop-name prop-schema]
-  (assert (keyword? db-ident))
-  (let [db-ident' (if (or (= "user.property" (namespace db-ident))
-                          (string/starts-with? (namespace db-ident) "logseq.")
-                          (contains? #{:block/tags :block/alias} db-ident))
-                    db-ident
-                    (keyword "user.property" (name db-ident)))]
-    (block-with-timestamps
-     (cond->
-      {:db/ident db-ident'
-       :block/type "property"
-       :block/journal? false
-       :block/format :markdown
-       :block/schema (merge {:type :default} prop-schema)
-       :block/name (common-util/page-name-sanity-lc (name prop-name))
-       :block/uuid (d/squuid)
-       :block/original-name (name prop-name)}
-       (= :many (:cardinality prop-schema))
-       (assoc :db/cardinality :db.cardinality/many)
-       (not= :many (:cardinality prop-schema))
-       (assoc :db/cardinality :db.cardinality/one)
-       (contains? property-ref-types (:type prop-schema))
-       (assoc :db/valueType :db.type/ref)
-       true
-       (assoc :db/index true)))))
+  "Build a standard new property so that it is is consistent across contexts. Takes
+   an optional map with following keys:
+   * :original-name - Case sensitive property name. Defaults to deriving this from db-ident"
+  ([db-ident prop-schema] (build-new-property db-ident prop-schema {}))
+  ([db-ident prop-schema {:keys [original-name]}]
+   (assert (keyword? db-ident))
+   (let [db-ident' (if (qualified-keyword? db-ident)
+                     db-ident
+                     (db-property/user-property-ident-from-name (name db-ident)))
+         prop-name (or original-name (name db-ident'))]
+     (block-with-timestamps
+      (cond->
+       {:db/ident db-ident'
+        :block/type "property"
+        :block/journal? false
+        :block/format :markdown
+        :block/schema (merge {:type :default} prop-schema)
+        :block/name (common-util/page-name-sanity-lc (name prop-name))
+        :block/uuid (d/squuid)
+        :block/original-name (name prop-name)
+        :db/index true
+        :db/cardinality (if (= :many (:cardinality prop-schema))
+                          :db.cardinality/many
+                          :db.cardinality/one)}
+        (contains? property-ref-types (:type prop-schema))
+        (assoc :db/valueType :db.type/ref))))))
 
 
 (defn build-new-class

+ 6 - 6
deps/db/test/logseq/db/frontend/rules_test.cljs

@@ -19,8 +19,8 @@
 
 (deftest has-page-property-rule
   (let [conn (new-db-conn)
-        _ (d/transact! conn [(sqlite-util/build-new-property :user.property/foo "foo" {})
-                             (sqlite-util/build-new-property :user.property/foo2 "foo2" {})
+        _ (d/transact! conn [(sqlite-util/build-new-property :user.property/foo {})
+                             (sqlite-util/build-new-property :user.property/foo2 {})
                              (sqlite-util/build-new-page "Page")
                              {:block/original-name "Page" :user.property/foo "bar"}])]
     (is (= ["Page"]
@@ -41,10 +41,10 @@
 
 (deftest page-property-rule
   (let [conn (new-db-conn)
-        _ (d/transact! conn [(sqlite-util/build-new-property :user.property/foo "foo" {})
-                             (sqlite-util/build-new-property :user.property/foo2 "foo2" {})
-                             (sqlite-util/build-new-property :user.property/number-many "number-many" {:type :number :cardinality :many})
-                             (sqlite-util/build-new-property :user.property/page-many "page-many" {:type :page :cardinality :many})
+        _ (d/transact! conn [(sqlite-util/build-new-property :user.property/foo {})
+                             (sqlite-util/build-new-property :user.property/foo2 {})
+                             (sqlite-util/build-new-property :user.property/number-many {:type :number :cardinality :many})
+                             (sqlite-util/build-new-property :user.property/page-many {:type :page :cardinality :many})
                              (sqlite-util/build-new-page "Page")
                              (sqlite-util/build-new-page "Page A")
                              {:block/original-name "Page" :user.property/foo "bar"}

+ 7 - 3
deps/db/test/logseq/db/sqlite/create_graph_test.cljs

@@ -6,6 +6,7 @@
             [logseq.db.frontend.schema :as db-schema]
             [logseq.db.sqlite.create-graph :as sqlite-create-graph]
             [logseq.db.frontend.validate :as db-validate]
+            [logseq.db.frontend.property :as db-property]
             [logseq.db :as ldb]))
 
 (deftest new-graph-db-idents
@@ -24,7 +25,8 @@
         (is (= '() (remove namespace default-idents))
             "All default :db/ident's have namespaces")
         (is (= []
-               (->> (keep namespace default-idents)
+               (->> (remove db-property/db-attribute-properties default-idents)
+                    (keep namespace)
                     (remove #(string/starts-with? % "logseq."))))
             "All default :db/ident namespaces start with logseq."))
 
@@ -47,8 +49,10 @@
         idents (->> (d/q '[:find [(pull ?b [:db/ident :logseq.property/built-in?]) ...]
                            :where [?b :db/ident]]
                          @conn)
-                    ;; only kv's don't have built-in property
-                    (remove #(= "logseq.kv" (namespace (:db/ident %)))))]
+                    ;; only kv's and empty property value aren't marked because
+                    ;; they aren't user facing
+                    (remove #(or (= "logseq.kv" (namespace (:db/ident %)))
+                                 (= :logseq.property/empty-placeholder (:db/ident %)))))]
     (is (= []
            (remove ldb/built-in? idents))
         "All entities with :db/ident have built-in property (except for kv idents)")))

+ 4 - 4
deps/outliner/src/logseq/outliner/core.cljs

@@ -650,11 +650,11 @@
          (let [list? (and (some? (:block/uuid block))
                           (nil? (list-type-fn block)))]
            (cond-> block
-             (and db-based? list?)
-             (assoc k list-type)
-
              list?
-             (update :block/properties assoc k list-type)
+             ((fn [b]
+                (if db-based?
+                  (assoc b k list-type)
+                  (update b :block/properties assoc k list-type))))
 
              (not db-based?)
              (assoc :block/content (gp-property/insert-property repo format content :logseq.order-list-type list-type)))))

+ 10 - 11
scripts/src/logseq/tasks/db_graph/create_graph.cljs

@@ -68,7 +68,7 @@
   (->> properties
        (map
         (fn [[prop-name val]]
-          [(db-property/get-db-ident-from-name (name prop-name))
+          [(db-property/user-property-ident-from-name (name prop-name))
             ;; set indicates a :many value
            (if (set? val)
              (set (map #(translate-property-value % uuid-maps) val))
@@ -105,7 +105,7 @@
 (defn- build-property-refs [properties property-db-ids]
   (mapv
    (fn [prop-name]
-     (db-property/get-db-ident-from-name (name prop-name)))
+     (db-property/user-property-ident-from-name (name prop-name)))
    (keys properties)))
 
 (def current-db-id (atom 0))
@@ -168,7 +168,7 @@
                            (mapcat
                             (fn [[prop-name]]
                               (if (get-in properties [prop-name :closed-values])
-                                (let [db-ident (db-property/get-db-ident-from-name (name prop-name))]
+                                (let [db-ident (db-property/user-property-ident-from-name (name prop-name))]
                                   (db-property-util/build-closed-values
                                    db-ident
                                    prop-name
@@ -178,14 +178,13 @@
                                     :property-attributes
                                     {:db/id (or (property-db-ids (name prop-name))
                                                 (throw (ex-info "No :db/id for property" {:property prop-name})))}}))
-                                [(let [db-ident (keyword "user.property" (name prop-name))]
-                                   (merge
-                                    (sqlite-util/build-new-property db-ident prop-name (get-in properties [prop-name :block/schema]))
-                                    {:db/id (or (property-db-ids (name prop-name))
-                                                (throw (ex-info "No :db/id for property" {:property prop-name})))}
-                                    (when-let [props (not-empty (get-in properties [prop-name :properties]))]
-                                      (assoc (->block-properties-tx props uuid-maps)
-                                             :block/refs (build-property-refs props property-db-ids)))))]))
+                                [(merge
+                                  (sqlite-util/build-new-property prop-name (get-in properties [prop-name :block/schema]))
+                                  {:db/id (or (property-db-ids (name prop-name))
+                                              (throw (ex-info "No :db/id for property" {:property prop-name})))}
+                                  (when-let [props (not-empty (get-in properties [prop-name :properties]))]
+                                    (assoc (->block-properties-tx props uuid-maps)
+                                           :block/refs (build-property-refs props property-db-ids))))]))
                             property-uuids))
         pages-and-blocks-tx
         (vec

+ 2 - 2
src/main/frontend/components/property.cljs

@@ -171,7 +171,7 @@
                                     {id true}))
                 (property-handler/set-block-property! repo (:block/uuid block)
                                                       property-name
-                                                      (if (= type :default) "" :property/empty-placeholder)))))))}
+                                                      (if (= type :default) "" :logseq.property/empty-placeholder)))))))}
       (shui/select-trigger
        {:class "!px-2 !py-0 !h-8"}
        (shui/select-value
@@ -446,7 +446,7 @@
                                (map #(:block/original-name (db/entity %)))
                                (remove nil?)
                                (set))
-        existing-tag-alias (->> [:block/tags :block/alias]
+        existing-tag-alias (->> db-property/db-attribute-properties
                                 (map db-property/built-in-properties)
                                 (keep #(when (get entity (:attribute %)) (:original-name %)))
                                 set)

+ 5 - 5
src/main/frontend/components/property/value.cljs

@@ -179,7 +179,7 @@
   [block property {:keys [items selected-choices multiple-choices?] :as opts}]
   (let [selected-choices (->> selected-choices
                               (remove nil?)
-                              (remove #(= :property/empty-placeholder %)))
+                              (remove #(= :logseq.property/empty-placeholder %)))
         clear-value (str "No " (:block/original-name property))
         items' (->>
                 (if (and (seq selected-choices) (not multiple-choices?))
@@ -187,7 +187,7 @@
                          :label clear-value}
                         items)
                   items)
-                (remove #(= :property/empty-placeholder (:value %))))
+                (remove #(= :logseq.property/empty-placeholder (:value %))))
         k (if multiple-choices? :on-apply :on-chosen)
         f (get opts k)
         f' (fn [chosen]
@@ -569,7 +569,7 @@
   (let [closed-values? (seq (get-in property [:block/schema :values]))]
     [:div.select-item
      (cond
-       (= value :property/empty-placeholder)
+       (= value :logseq.property/empty-placeholder)
        (shui/button {:class "empty-btn" :variant :text} "Empty")
 
        (contains? #{:page :date} type)
@@ -715,7 +715,7 @@
         select-type? (select-type? property type)
         closed-values? (seq (:values schema))
         select-opts {:on-chosen on-chosen}
-        value (if (and (de/entity? value) (= (:db/ident value) :property/empty-placeholder))
+        value (if (and (de/entity? value) (= (:db/ident value) :logseq.property/empty-placeholder))
                 nil
                 value)]
     (if (and select-type?
@@ -815,7 +815,7 @@
          schema (:block/schema property)
          type (some-> schema (get :type :default))
          multiple-values? (= :many (:cardinality schema))
-         empty-value? (= :property/empty-placeholder v)
+         empty-value? (= :logseq.property/empty-placeholder v)
          editor-args {:block property
                       :parent-block block
                       :format :markdown}

+ 4 - 4
src/main/frontend/db/async.cljs

@@ -15,8 +15,8 @@
             [cljs-time.core :as t]
             [cljs-time.format :as tf]
             [logseq.db :as ldb]
-            [clojure.string :as string]
-            [frontend.util :as util]))
+            [frontend.util :as util]
+            [logseq.db.frontend.property :as db-property]))
 
 (def <q db-async-util/<q)
 (def <pull db-async-util/<pull)
@@ -58,7 +58,7 @@
     (->> result
          ;; remove private built-in properties
          (remove #(and (:db/ident %)
-                       (string/starts-with? (namespace (:db/ident %)) "logseq.")
+                       (db-property/logseq-property? (:db/ident %))
                        (not (get-in % [:block/schema :public?])))))))
 
 (defn <get-all-property-names
@@ -82,7 +82,7 @@
         :in $ ?property-id
         :where
         [?b ?property-id ?v]
-        [(not= ?v :property/empty-placeholder)]]
+        [(not= ?v :logseq.property/empty-placeholder)]]
       property-id))
 
 ;; TODO: batch queries for better performance and UX

+ 10 - 10
src/main/frontend/handler/db_based/property.cljs

@@ -108,7 +108,7 @@
    Two main  ways to create a property are to set property-id to a qualified keyword
    or to set it to nil and pass :property-name as an option"
   [repo property-id schema {:keys [property-name properties]}]
-  (let [db-ident (or property-id (db-property/get-db-ident-from-name property-name))]
+  (let [db-ident (or property-id (db-property/user-property-ident-from-name property-name))]
     (assert (qualified-keyword? db-ident))
     (if-let [property (db/entity db-ident)]
       (let [tx-data (->>
@@ -132,7 +132,7 @@
                        (name property-id))]
         (assert (some? k-name)
                 (prn "property-id: " property-id ", property-name: " property-name))
-        (db/transact! repo [(sqlite-util/build-new-property db-ident k-name schema)]
+        (db/transact! repo [(sqlite-util/build-new-property db-ident schema {:original-name k-name})]
                       {:outliner-op :new-property})))))
 
 (defn validate-property-value
@@ -157,7 +157,7 @@
                       (catch :default e
                         (notification/show! (str e) :error false)
                         nil))
-            tags-or-alias? (contains? #{:block/tags :block/alias} property-id)
+            tags-or-alias? (contains? db-property/db-attribute-properties property-id)
             old-values (if tags-or-alias?
                          (->> (get block property-id)
                               (map (fn [e] (:db/id e))))
@@ -203,7 +203,7 @@
   [repo block-eid property-id v {:keys [property-name] :as opts}]
   (let [block-eid (->eid block-eid)
         property-id (if (string? property-id)
-                      (db-property/get-db-ident-from-name property-id)
+                      (db-property/user-property-ident-from-name property-id)
                       property-id)
         _ (assert (keyword? property-id) "property-id should be a keyword")
         block (db/entity repo block-eid)
@@ -222,7 +222,7 @@
                 schema (get (built-in-validation-schemas property) property-type)
                 value (when-let [id (:db/ident property)]
                         (get block id))
-                v* (if (= v :property/empty-placeholder)
+                v* (if (= v :logseq.property/empty-placeholder)
                      v
                      (try
                        (convert-property-input-string property-type v)
@@ -230,19 +230,19 @@
                          (js/console.error e)
                          (notification/show! (str e) :error false)
                          nil)))
-                tags-or-alias? (and (contains? #{:block/tags :block/alias} property-id) (uuid? v*))]
+                tags-or-alias? (and (contains? db-property/db-attribute-properties property-id) (uuid? v*))]
             (if tags-or-alias?
               (let [property-value-id v*]
                 (db/transact! repo
                               [[:db/add (:db/id block) property-id property-value-id]]
                               {:outliner-op :save-block}))
               (when-not (contains? (if (set? value) value #{value}) v*)
-                (if-let [msg (when-not (= v* :property/empty-placeholder) (validate-property-value schema v*))]
+                (if-let [msg (when-not (= v* :logseq.property/empty-placeholder) (validate-property-value schema v*))]
                   (let [msg' (str "\"" k-name "\"" " " (if (coll? msg) (first msg) msg))]
                     (notification/show! msg' :warning))
                   (let [_ (upsert-property! repo property-id (assoc property-schema :type property-type) {:property-name property-name})
                         status? (= :logseq.task/status (:db/ident property))
-                        value (if (= value :property/empty-placeholder) [] value)
+                        value (if (= value :logseq.property/empty-placeholder) [] value)
                         new-value (cond
                                     multiple-values?
                                     (let [f (if (coll? v*) concat conj)]
@@ -272,7 +272,7 @@
             (if (string? property-id)
               (if-let [ent (db/entity [:block/original-name property-id])]
                 [(:db/ident ent) ent]
-                [(db-property/get-db-ident-from-name property-id) nil])
+                [(db-property/user-property-ident-from-name property-id) nil])
               [property-id (db/entity property-id)])
             property-type (get-in property [:block/schema :type])
             _ (upsert-property! repo db-ident
@@ -364,7 +364,7 @@
 (defn remove-block-property!
   [repo eid property-id]
   (let [eid (->eid eid)]
-    (if (contains? #{:block/alias :block/tags} property-id)
+    (if (contains? db-property/db-attribute-properties property-id)
      (when-let [block (db/entity eid)]
        (db/transact! repo
                      [[:db/retract (:db/id block) property-id]]

+ 1 - 1
src/main/frontend/handler/property/util.cljs

@@ -24,7 +24,7 @@
                         (name key)
                         key)]
     (if (sqlite-util/db-based-graph? repo)
-      (when-let [property (d/entity db (db-property/get-db-ident-from-name property-name))]
+      (when-let [property (d/entity db (db-property/user-property-ident-from-name property-name))]
         (get coll (:block/uuid property)))
       (get coll key))))