Skip to content

fix: block property values deletion#12650

Merged
RCmerci merged 3 commits into
masterfrom
fix/residual-property-value
May 14, 2026
Merged

fix: block property values deletion#12650
RCmerci merged 3 commits into
masterfrom
fix/residual-property-value

Conversation

@RCmerci
Copy link
Copy Markdown
Contributor

@RCmerci RCmerci commented May 14, 2026

Summary

Fixes generated default/url property value blocks so they are owned by the block that uses them when values are created through block property updates.

Previously, CLI-style property updates such as upsert block --update-properties '{"xxx" "x1"}' could create the generated value block under the property entity. When the owning block was deleted, that value block was outside the deleted block subtree and remained in the graph database.

This change passes the owning block context into property value creation for default/url ref values, so generated values are attached to the block and are removed with it.

Testing

  • bb dev:test -v frontend.db.property-values-test/deleting-block-removes-cli-created-default-property-values-test
  • bb dev:test -n frontend.db.property-values-test
  • bb -f cli-e2e/bb.edn build
  • Manual CLI reproduction with a temporary graph:
    • created a many default property xxx
    • set {"xxx" "x1"} on block1
    • verified the generated value block parent is block1
    • deleted block1
    • verified the generated value block returns entity-not-found
  • clojure -M:clj-kondo --lint src test in deps/outliner
  • bb lint:carve in deps/outliner
  • bb lint:large-vars in deps/outliner

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes ownership of generated default/url property value blocks so values created via block property updates are attached under the owning block and are removed when that block is deleted.

Changes:

  • Passes block context through ref property value conversion for generated default/url values.
  • Defers default/url value conversion in batch updates until each target block is known.
  • Adds a regression test for deleting a block with a CLI-style generated default property value.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
deps/outliner/src/logseq/outliner/property.cljs Updates default/url property value creation to receive the owning block id during conversion.
src/test/frontend/db/property_values_test.cljs Adds a deletion regression test for generated default property values owned by a block.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

;; FIXME: remove this when :logseq.property/order-list-type updated to closed values
(not= property-id :logseq.property/order-list-type))
(let [v-uuid (create-property-text-block! conn nil property-id v {})]
(let [v-uuid (create-property-text-block! conn block-id property-id v {})]
Comment on lines +53 to +71
(let [property-ident :user.property/xxx-IiHzt48w
conn (db-test/create-conn-with-blocks
{:properties {property-ident {:logseq.property/type :default
:db/cardinality :db.cardinality/many
:logseq.property/public? true
:block/title "xxx"}}
:pages-and-blocks [{:page {:block/title "page1"}
:blocks [{:block/title "block1"}]}]})
block (db-test/find-block-by-content @conn "block1")
block-uuid (:block/uuid block)]
(outliner-property/batch-set-property! conn [block-uuid] property-ident "x1")
(let [block (d/entity @conn [:block/uuid block-uuid])
value (first (get block property-ident))
value-id (:db/id value)]
(is (= (:db/id block) (:db/id (:block/parent value)))
"Generated default property value blocks should be owned by their block")
(outliner-core/delete-blocks! conn [block] {})
(is (nil? (d/entity @conn value-id))
"Deleting the owning block removes its generated property value block"))))
@RCmerci RCmerci force-pushed the fix/residual-property-value branch from 77abe6a to fc51c77 Compare May 14, 2026 13:13
@RCmerci RCmerci merged commit ebb2278 into master May 14, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants