fix: changing property type or cardinality

doesn't update its timestamp. Changing a property's core behavior is
worthy of a timestamp update
This commit is contained in:
Gabriel Horner
2025-01-20 17:12:16 -05:00
parent bb1f20048c
commit 7b2d5ceebd
2 changed files with 8 additions and 4 deletions

View File

@@ -93,8 +93,9 @@
old-ref-type? (db-property-type/user-ref-property-types old-type)
ref-type? (db-property-type/user-ref-property-types new-type)]
(cond-> [(cond->
{:db/ident ident
:db/cardinality cardinality}
(outliner-core/block-with-updated-at
{:db/ident ident
:db/cardinality cardinality})
ref-type?
(assoc :db/valueType :db.type/ref))]
(and new-type old-ref-type? (not ref-type?))

View File

@@ -16,8 +16,11 @@
(testing "Updates a property"
(let [conn (db-test/create-conn-with-blocks {:properties {:num {:logseq.property/type :number}}})
_ (outliner-property/upsert-property! conn :user.property/num {:type :default :cardinality :many} {})]
(is (db-property/many? (d/entity @conn :user.property/num)))))
old-updated-at (:block/updated-at (d/entity @conn :user.property/num))
_ (outliner-property/upsert-property! conn :user.property/num {:cardinality :many} {})]
(is (db-property/many? (d/entity @conn :user.property/num)))
(is (> (:block/updated-at (d/entity @conn :user.property/num))
old-updated-at))))
(testing "Multiple properties that generate the same initial :db/ident"
(let [conn (db-test/create-conn-with-blocks [])]