Tienson Qin пре 1 недеља
родитељ
комит
8a4fa601d2

+ 1 - 1
deps/db/src/logseq/db.cljs

@@ -93,7 +93,7 @@
           db @conn
           db-based? (entity-plus/db-based-graph? db)
           [validate-result tx-report] (if (and db-based?
-                                               (:pipeline-replace? tx-meta)
+                                               (not (:pipeline-replace? tx-meta))
                                                (not (:reset-conn! tx-meta))
                                                (not (:skip-validate-db? tx-meta false)))
                                         (let [tx-report (d/with db tx-data tx-meta)]

+ 21 - 2
deps/db/src/logseq/db/frontend/property/build.cljs

@@ -111,7 +111,10 @@
                   (assert (:db/ident property-map) "Key in map must have a :db/ident")
                   (when pure? (assert (some? gen-uuid-value-prefix) block))
                   [(or (:original-property-id property-map) (:db/ident property-map))
-                   (if (set? v)
+                   (cond
+                     (and (set? v) (every? uuid? v))
+                     (set (map #(vector :block/uuid %) v))
+                     (set? v)
                      (set (map #(build-property-value-block
                                  block' property-map %
                                  (cond-> {}
@@ -121,6 +124,9 @@
                                    (assoc :block-uuid
                                           (common-uuid/gen-uuid :builtin-block-uuid (str gen-uuid-value-prefix "-" %)))))
                                v))
+                     (uuid? v)
+                     [:block/uuid v]
+                     :else
                      (build-property-value-block block' property-map v
                                                  (cond-> {}
                                                    property-value-properties
@@ -130,12 +136,25 @@
                                                           (common-uuid/gen-uuid :builtin-block-uuid (str gen-uuid-value-prefix "-" v))))))])))
          (into {}))))
 
+(defn- lookup-id?
+  [v]
+  (and (vector? v)
+       (= 2 (count v))
+       (= :block/uuid (first v))
+       (uuid? (second v))))
+
 (defn build-properties-with-ref-values
   "Given a properties map with property values to be transacted e.g. from
   build-property-values-tx-m, build a properties map to be transacted with the block"
   [prop-vals-tx-m]
   (update-vals prop-vals-tx-m
                (fn [v]
-                 (if (set? v)
+                 (cond
+                   (and (set? v) (every? lookup-id? v))
+                   v
+                   (set? v)
                    (set (map #(vector :block/uuid (:block/uuid %)) v))
+                   (lookup-id? v)
+                   v
+                   :else
                    (vector :block/uuid (:block/uuid v))))))

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

@@ -135,7 +135,7 @@
     (string? s)
     (when-let [ent (d/entity db s)]
       (and (string? (:block/title ent))
-           (:block/page ent)))))
+           (some? (:block/page ent))))))
 
 (defn- node-entity?
   [db val]

+ 17 - 4
deps/db/src/logseq/db/sqlite/build.cljs

@@ -140,9 +140,20 @@
                     (cond-> property-map
                       (and (:build/property-value v) (seq pvalue-attrs))
                       (assoc :property-value-properties pvalue-attrs)))
-                  (if (:build/property-value v)
-                    (or (:logseq.property/value v) (:block/title v))
-                    v)])))
+                  (let [property (when (keyword? k) (get properties-config k))
+                        closed-value-id (when property (some (fn [item]
+                                                               (when (= (:value item) v)
+                                                                 (:uuid item)))
+                                                             (get property :build/closed-values)))]
+                    (cond
+                      closed-value-id
+                      closed-value-id
+
+                      (:build/property-value v)
+                      (or (:logseq.property/value v) (:block/title v))
+
+                      :else
+                      v))])))
        (db-property-build/build-property-values-tx-m new-block)))
 
 (defn- extract-basic-content-refs
@@ -502,7 +513,9 @@
         [init-tx block-props-tx]
         (reduce (fn [[init-tx* block-props-tx*] m]
                   (let [props (select-keys m property-idents)]
-                    [(conj init-tx* (apply dissoc m property-idents))
+                    [(if (map? m)
+                       (conj init-tx* (apply dissoc m property-idents))
+                       init-tx*)
                      (if (seq props)
                        (conj block-props-tx*
                              (merge {:block/uuid (or (:block/uuid m)

+ 4 - 4
src/test/frontend/db/query_dsl_test.cljs

@@ -294,11 +294,11 @@ prop-d:: [[nada]]"}])
                  {:block/title "bug2"
                   :build/tags [:Bug]}]}]})
 
-    (is (= ["task2" "bug2"]
-           (map :block/title (dsl-query "(property status \"Todo\")")))
+    (is (= #{"task2" "bug2"}
+           (set (map :block/title (dsl-query "(property status \"Todo\")"))))
         "Blocks or tagged with or descended from a tag that has closed default-value property")
-    (is (= ["task1" "bug1"]
-           (map :block/title (dsl-query "(property status \"Doing\")")))
+    (is (= #{"task1" "bug1"}
+           (set (map :block/title (dsl-query "(property status \"Doing\")"))))
         "Blocks or tagged with or descended from a tag that don't have closed default-value property value")))
 
 (deftest block-property-query-performance