Pārlūkot izejas kodu

fix(regression): query builder for multiple property types including :checkbox

Fixes https://github.com/logseq/db-test/issues/288. Regression caused by
572d6f4390cc2e9e5ee81503d84f03d733b01344 . Confirmed this bug was
affecting the following non-ref, non-string property types:
:checkbox, :any, :keyword and :raw-number
Gabriel Horner 4 mēneši atpakaļ
vecāks
revīzija
04190d22a3

+ 4 - 1
deps/db/src/logseq/db/common/view.cljs

@@ -476,7 +476,10 @@
                                    [label value] (cond ref-type?
                                                        [(db-property/property-value-content e)
                                                         (select-keys e [:db/id :block/uuid])]
-                                                       (= :datetime (:logseq.property/type property))
+                                                       ;; FIXME: Move query concerns out of :label as UI labels are usually strings
+                                                       ;; All non-string values need to be passed to the query builder since non-ref prop values use the actual value
+                                                       ;; This check is less fragile than listing all the property types to support e.g. :datetime, :checkbox, :keyword, :any
+                                                       (not (string? v))
                                                        [v v]
                                                        :else
                                                        [(str v) v])]

+ 7 - 4
src/main/frontend/components/query/builder.cljs

@@ -171,17 +171,20 @@
   [*property *private-property? *find *tree opts loc values {:keys [db-graph?]}]
   (let [values' (cons {:label "Select all"
                        :value "Select all"}
-                      values)
+                      (map #(hash-map :value (str (:value %))
+                                      ;; Preserve original-value as non-string values like boolean do not display in select
+                                      :original-value (:value %))
+                           values))
         find' (rum/react *find)]
     (select values'
-            (fn [{:keys [value]}]
+            (fn [{:keys [value original-value]}]
               (let [k (cond
                         db-graph? (if @*private-property? :private-property :property)
                         (= find' :page) :page-property
                         :else :property)
                     x (if (= value "Select all")
                         [k @*property]
-                        [k @*property value])]
+                        [k @*property original-value])]
                 (reset! *property nil)
                 (append-tree! *tree opts loc x))))))
 
@@ -193,7 +196,7 @@
      (fn [_property]
        (p/let [result (if db-graph?
                         (p/let [result (db-async/<get-property-values @*property)]
-                          (map (fn [{:keys [label _value]}]
+                          (map (fn [{:keys [label]}]
                                  {:label label
                                   :value label})
                                result))