Skip to content

Adding draft documents with createIfNotExists overwrites published version #414

Open
@DarkSymm

Description

@DarkSymm

I am adding documents from an external source using the createIfNotExists method. The documents are added as drafts and then are manually adjusted before publishing.

I noticed that everything is reverted to draft after re-importing. It appears that once published if the document is re-submitted as a draft to the createIfNotExists method, the published document gets overwritten with the draft content and reverted back to a draft.

To Reproduce

Import a document as a draft (by appending 'drafts.' to the id) using the createIfNotExists method when there is a published document with the same ID. It will overwrite the published content and set the document as a draft.

Expected behavior

When submitting a draft with the createIfNotExists — if there is already a corresponding published version — it will not overwrite exiting document.

Which versions of Sanity are you using?

@sanity/cli (global) 3.20.0 (latest: 3.20.1)
@sanity/cross-dataset-duplicator 1.2.3 (up to date)
@sanity/eslint-config-studio 3.0.1 (up to date)
@sanity/vision 3.20.1 (up to date)
sanity 3.20.1 (up to date)

What operating system are you using?

Mac OS 14.1.1

Which versions of Node.js / npm are you running?

npm 10.2.4
node v20.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions