fix: keep property ops uuid-only

This commit is contained in:
Tienson Qin
2026-04-15 04:37:32 +08:00
parent 5d870d9a15
commit 9d292435c8
5 changed files with 28 additions and 10 deletions

View File

@@ -100,6 +100,26 @@
(is (= "some content"
(:block/title (:plugin.property._test_plugin/x8 block'))))))))
(deftest remove-block-property-op-rejects-lookup-ref-block-id-test
(testing "remove-block-property rejects lookup-ref block ids"
(let [conn (db-test/create-conn-with-blocks
[{:page {:block/title "Test"}
:blocks [{:block/title "Block"}]}])
block (db-test/find-block-by-content @conn "Block")
block-uuid (:block/uuid block)]
(outliner-property/set-block-property! conn
[:block/uuid block-uuid]
:logseq.property/order-list-type
"number")
(is (some? (:logseq.property/order-list-type
(d/entity @conn [:block/uuid block-uuid]))))
(is (thrown? js/Error
(outliner-op/apply-ops!
conn
[[:remove-block-property [[:block/uuid block-uuid]
:logseq.property/order-list-type]]]
{}))))))
(deftest direct-plugin-many-page-property-appends-values-test
(testing "direct property operations keep both page values"
(let [conn (db-test/create-conn-with-blocks

View File

@@ -135,7 +135,7 @@
(defn update-public-attribute!
[page value]
(db-property-handler/set-block-property! [:block/uuid (:block/uuid page)] :logseq.property/publishing-public? value))
(db-property-handler/set-block-property! (:block/uuid page) :logseq.property/publishing-public? value))
(defn get-page-ref-text
[page]

View File

@@ -7,16 +7,14 @@
(defn remove-block-property!
[block-id property-id-or-key]
(assert (some? property-id-or-key) "remove-block-property! remove-block-property! is nil")
(let [eid (if (uuid? block-id) [:block/uuid block-id] block-id)]
(db-property-handler/remove-block-property! eid property-id-or-key)))
(db-property-handler/remove-block-property! block-id property-id-or-key))
(defn set-block-property!
[block-id key v]
(assert (some? key) "set-block-property! key is nil")
(let [eid (if (uuid? block-id) [:block/uuid block-id] block-id)]
(if (or (nil? v) (and (coll? v) (empty? v)))
(db-property-handler/remove-block-property! eid key)
(db-property-handler/set-block-property! eid key v))))
(if (or (nil? v) (and (coll? v) (empty? v)))
(db-property-handler/remove-block-property! block-id key)
(db-property-handler/set-block-property! block-id key v)))
(defn batch-remove-block-property!
[block-ids key]

View File

@@ -2320,7 +2320,7 @@
:block/order "a0"}
nil]]]
:db-sync/inverse-outliner-ops
[[:remove-block-property [[:block/uuid source-uuid]
[[:remove-block-property [source-uuid
:logseq.property/query]]
[:delete-blocks [[[:block/uuid query-block-uuid]]
{}]]]

View File

@@ -554,7 +554,7 @@
(let [conn (worker-state/get-datascript-conn test-repo)
block-uuid (:block/uuid (db-test/find-block-by-content @conn "task"))]
(apply-ops! conn
[[:set-block-property [[:block/uuid block-uuid]
[[:set-block-property [block-uuid
:logseq.property/status
:logseq.property/status.todo]]]
(local-tx-meta {:client-id "test-client"}))
@@ -1120,7 +1120,7 @@
(local-tx-meta {:client-id "test-client"}))
(worker-undo-redo/clear-history! test-repo)
(apply-ops! conn
[[:set-block-property [[:block/uuid child-uuid]
[[:set-block-property [child-uuid
property-id
"value-1"]]]
(local-tx-meta {:client-id "test-client"}))