Repository navigation
fix(outliner): do not revert many to one on undo - #13526
Conversation
Review — fix(outliner): do not revert many to one on undoThe core fix is correct: the recorded inverse now omits Findings[Important] Omitted cardinality now preserves Location: Issue: when a schema omits Impact: invalid Suggestion: when [Important] The same throw path remains on Location: Issue: undoing a property-page delete rebuilds the property with Suggestion: reuse [Minor] Values added between the toggle and the undo still throw The omission decision is made at record time against [Question]
Verification
System additions
|
Keep :db.cardinality/many when undoing a one-to-many toggle that already has values. The inverse omits :db/cardinality so undo does not throw or clear history. Co-authored-by: Tienson Qin <[email protected]>
Closed-value properties still run a schema update on undo. Missing :db/cardinality must not default to :one. Co-authored-by: Tienson Qin <[email protected]>
Coerce types that cannot be :many back to :one. Skip an unsafe cardinality restore when a replayed schema has other fields. Co-authored-by: Tienson Qin <[email protected]>
Co-authored-by: Tienson Qin <[email protected]>
67bc381 to
bdd614f
Compare
| (if (and many->one? has-values?) | ||
| (if (seq (dissoc schema :db/cardinality)) | ||
| (dissoc schema :db/cardinality) | ||
| (throw-disallowed-many-to-one!)) |
There was a problem hiding this comment.
🟡 Multi-field cardinality change silently fails
With existing values, schema-for-update silently drops a requested :one conversion whenever the schema includes another field. The upsert succeeds but leaves the property at :many.
Learn more
An upsert can update a property schema directly, not just replay an undo operation. For a property with existing values and cardinality :many, a request containing :db/cardinality :one plus any other field reaches this branch. It drops the cardinality and completes normally, while a cardinality-only request raises an error. The caller cannot detect that the requested conversion failed.
Example: Given a populated :user.property/note with cardinality :many, (upsert-property! conn :user.property/note {:db/cardinality :one :logseq.property/type :default} {}) returns while the property remains :many; passing only {:db/cardinality :one} throws.
Recommended fix: Separate undo replay behavior from ordinary upsert-property! requests, or reject explicit many-to-one requests consistently. Preserve the inverse's ability to omit cardinality through inverse-upsert-property-schema without silently accepting direct conversion requests.
Was this helpful? React with 👍 or 👎 to provide feedback.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
* fix(outliner): do not revert many to one on undo Keep :db.cardinality/many when undoing a one-to-many toggle that already has values. The inverse omits :db/cardinality so undo does not throw or clear history. Co-authored-by: Tienson Qin <[email protected]> * fix(outliner): keep cardinality when schema omits it Closed-value properties still run a schema update on undo. Missing :db/cardinality must not default to :one. Co-authored-by: Tienson Qin <[email protected]> * fix(outliner): keep many-to-one undo from invalid types Coerce types that cannot be :many back to :one. Skip an unsafe cardinality restore when a replayed schema has other fields. Co-authored-by: Tienson Qin <[email protected]> * fix(test): balance parens in property cardinality tests Co-authored-by: Tienson Qin <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
Keep :db.cardinality/many when undoing a one-to-many toggle that already has values. The inverse omits :db/cardinality so undo does not throw or clear history.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
* fix(outliner): do not revert many to one on undo Keep :db.cardinality/many when undoing a one-to-many toggle that already has values. The inverse omits :db/cardinality so undo does not throw or clear history. Co-authored-by: Tienson Qin <[email protected]> * fix(outliner): keep cardinality when schema omits it Closed-value properties still run a schema update on undo. Missing :db/cardinality must not default to :one. Co-authored-by: Tienson Qin <[email protected]> * fix(outliner): keep many-to-one undo from invalid types Coerce types that cannot be :many back to :one. Skip an unsafe cardinality restore when a replayed schema has other fields. Co-authored-by: Tienson Qin <[email protected]> * fix(test): balance parens in property cardinality tests Co-authored-by: Tienson Qin <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
Keep :db.cardinality/many when undoing a one-to-many toggle that already has values. The inverse omits :db/cardinality so undo does not throw or clear history.
* fix(outliner): do not revert many to one on undo Keep :db.cardinality/many when undoing a one-to-many toggle that already has values. The inverse omits :db/cardinality so undo does not throw or clear history. Co-authored-by: Tienson Qin <[email protected]> * fix(outliner): keep cardinality when schema omits it Closed-value properties still run a schema update on undo. Missing :db/cardinality must not default to :one. Co-authored-by: Tienson Qin <[email protected]> * fix(outliner): keep many-to-one undo from invalid types Coerce types that cannot be :many back to :one. Skip an unsafe cardinality restore when a replayed schema has other fields. Co-authored-by: Tienson Qin <[email protected]> * fix(test): balance parens in property cardinality tests Co-authored-by: Tienson Qin <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
logseq#13526's 2 tests check the inverse op of a one-to-many property change. With the datom replay, undo on a local graph uses no inverse op, so the tests run on a graph marked synced, where undo still replays the ops.
Related to logseq/db-test#1306 and the closed approach in #13480.
Reverting
:manyto:oneis not supported, including on undo.The previous inverse of
:upsert-propertyrestored the full prior schema, including:db/cardinality :db.cardinality/one. Applying that inverse threwDisallowed many to one conversionwhen values existed, so undo failed and cleared the history stack.Change
:upsert-propertyomits:db/cardinalitywhen restoring it would be many-to-one and the property already has values.update-datascript-schemakeeps the current cardinality when the schema omits it, except types that cannot be:many(:checkbox,:datetime) which coerce to:one.:oneplus other fields skips the cardinality change when values exist, instead of throwing. Cardinality-only many-to-one with data still throws.:db.cardinality/one.Tests
:manyproperty to checkbox/datetime restores:one; change to number keeps:many.:oneplus type keeps:manywhen values exist.