Skip to content

Commit 6f8d2a3

Browse files
committed
fix: tag and page names collision in query dsl
related to logseq/db-test#548
1 parent 323674a commit 6f8d2a3

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

deps/outliner/src/logseq/outliner/core.cljs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,6 @@
327327
(:block/title m*)
328328
(not= (:block/title m*) (:block/title block-entity)))
329329
(outliner-validate/validate-block-title db (:block/title m*) block-entity))
330-
_ (when (and db-based? (seq (:block/tags m*)))
331-
;; Add built-in? b/c it's not available here
332-
(doseq [tag (map #(assoc % :logseq.property/built-in?
333-
(contains? sqlite-create-graph/built-in-pages-names (:block/title %))) (:block/tags m*))]
334-
(outliner-validate/validate-built-in-pages tag {:message "Built-in page can't be a tag"})))
335330
m (cond-> m*
336331
db-based?
337332
(dissoc :block/format :block/pre-block? :block/priority :block/marker :block/properties-order))]

src/main/frontend/components/query/builder.cljs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,15 @@
218218
(let [result (db-model/get-all-readable-classes repo {:except-root-class? true})]
219219
(set-values! result)))
220220
[])
221-
(let [items (->> values
222-
(map :block/title)
223-
sort)]
221+
(let [items (->> (sort-by :block/title values)
222+
(map (fn [block]
223+
{:label (:block/title block)
224+
:value (:block/uuid block)})))]
224225
(select items
225-
(fn [{:keys [value]}]
226-
(append-tree! *tree opts loc [(if db-based? :tags :page-tags) value]))))))
226+
(fn [{:keys [value label]}]
227+
(append-tree! *tree opts loc [(if db-based? :tags :page-tags)
228+
(if db-based? (str value) label)]))
229+
{:extract-fn :label}))))
227230

228231
(rum/defc page-search
229232
[on-chosen]

src/main/frontend/db/query_dsl.cljs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,9 @@
427427
(let [db (db-conn/get-db)]
428428
(->> tags
429429
(mapcat (fn [tag-name]
430-
(when-let [tag-id (first (ldb/page-exists? db tag-name #{:logseq.class/Tag}))]
430+
(when-let [tag-id (if (common-util/uuid-string? tag-name)
431+
[:block/uuid (uuid tag-name)]
432+
(first (ldb/page-exists? db tag-name #{:logseq.class/Tag})))]
431433
(when-let [tag (db-utils/entity tag-id)]
432434
(->> (db-class/get-structured-children db (:db/id tag))
433435
(cons (:db/id tag)))))))

0 commit comments

Comments
 (0)