fix: block property values deletion#12650
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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")))) |
77abe6a to
fc51c77
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-testbb dev:test -n frontend.db.property-values-testbb -f cli-e2e/bb.edn buildmanydefault propertyxxx{"xxx" "x1"}onblock1block1block1entity-not-foundclojure -M:clj-kondo --lint src testindeps/outlinerbb lint:carveindeps/outlinerbb lint:large-varsindeps/outliner