Просмотр исходного кода

fix: property? should not treat classes as properties

Gabriel Horner 8 месяцев назад
Родитель
Сommit
2e19702afc

+ 6 - 0
deps/db/src/logseq/db/frontend/class.cljs

@@ -1,6 +1,7 @@
 (ns logseq.db.frontend.class
 (ns logseq.db.frontend.class
   "Class related fns for DB graphs and frontend/datascript usage"
   "Class related fns for DB graphs and frontend/datascript usage"
   (:require [clojure.set :as set]
   (:require [clojure.set :as set]
+            [clojure.string :as string]
             [datascript.core :as d]
             [datascript.core :as d]
             [flatland.ordered.map :refer [ordered-map]]
             [flatland.ordered.map :refer [ordered-map]]
             [logseq.common.defkeywords :refer [defkeywords]]
             [logseq.common.defkeywords :refer [defkeywords]]
@@ -153,3 +154,8 @@
   "Determines if keyword is a logseq class"
   "Determines if keyword is a logseq class"
   [kw]
   [kw]
   (= logseq-class (namespace kw)))
   (= logseq-class (namespace kw)))
+
+(defn user-class-namespace?
+  "Determines if namespace string is a user class"
+  [s]
+  (string/includes? s ".class"))

+ 0 - 6
deps/db/src/logseq/db/frontend/property.cljs

@@ -622,11 +622,6 @@
   [s]
   [s]
   (string/includes? s ".property"))
   (string/includes? s ".property"))
 
 
-(defn user-class-namespace?
-  "Determines if namespace string is a user class"
-  [s]
-  (string/includes? s ".class"))
-
 (defn internal-property?
 (defn internal-property?
   "Determines if ident kw is an internal property. This includes db-attribute properties
   "Determines if ident kw is an internal property. This includes db-attribute properties
    unlike logseq-property? and doesn't include non-property idents unlike internal-ident?"
    unlike logseq-property? and doesn't include non-property idents unlike internal-ident?"
@@ -643,7 +638,6 @@
     (and k-name
     (and k-name
          (or (contains? logseq-property-namespaces k-name)
          (or (contains? logseq-property-namespaces k-name)
              (user-property-namespace? k-name)
              (user-property-namespace? k-name)
-             (user-class-namespace? k-name)
              ;; disallow private db-attribute-properties as they cause unwanted refs
              ;; disallow private db-attribute-properties as they cause unwanted refs
              ;; and appear noisily in debugging contexts
              ;; and appear noisily in debugging contexts
              (and (keyword? k) (contains? public-db-attribute-properties k))))))
              (and (keyword? k) (contains? public-db-attribute-properties k))))))

+ 2 - 1
deps/db/src/logseq/db/sqlite/build.cljs

@@ -66,7 +66,8 @@
 (defn- get-ident [all-idents kw]
 (defn- get-ident [all-idents kw]
   (if (and (qualified-keyword? kw)
   (if (and (qualified-keyword? kw)
            ;; Loosen checks to any property or class for build-existing-tx?
            ;; Loosen checks to any property or class for build-existing-tx?
-           (db-property/property? kw))
+           (or (db-property/property? kw)
+               (db-class/user-class-namespace? (namespace kw))))
     kw
     kw
     (or (get all-idents kw)
     (or (get all-idents kw)
         (throw (ex-info (str "No ident found for " (pr-str kw)) {})))))
         (throw (ex-info (str "No ident found for " (pr-str kw)) {})))))