Skip to content

"id" field in document gets removed when creating a document #490

@slenin

Description

@slenin

Describe the bug
When a document has both "_id" and "id" field, the "id" field is removed. However, I am able to have a document with both fields when created through the Cloudant dashboard.

To Reproduce
sample_document = {
"_id": "70b63682-b93a-4c77-aad2-65501347265f4",
"id": "1",
"name": "Yamba",
"quantity": 10.5,
"sale": False,
}
document: Document = Document.from_dict(sample_document)
client.post_document(
db="testdb",
document=document
).get_result()

Document in the store is
{
"_id": "70b63682-b93a-4c77-aad2-65501347265f4",
"_rev": "1-d5a833fdf112ec7c7d85dde1cbed7878",
"name": "Yamba",
"quantity": 10.5,
"sale": false
}

Document.from_dict seems to remove the "id" field. Are there any workarounds to keep both fields?

Expected behavior
The document in the store should be
{
"_id": "70b63682-b93a-4c77-aad2-65501347265f4",
"_rev": "1-d5a833fdf112ec7c7d85dde1cbed7878",
"id": "1",
"name": "Yamba",
"quantity": 10.5,
"sale": false
}

Must gather (please complete the following information):

  • SDK Version 0.4.2
  • Python 3.11
  • IBM Cloudant
  • post_document

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions