-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"id" field in document gets removed when creating a document #490
Comments
Using BinaryIO has expected behavior sample_document = { docbytes = json.dumps(sample_document).encode('utf-8') |
The internal representation of the As you have already discovered one workaround is to use binary IO, which is the means by which the SDK allows for more flexible user-controlled serialization and deserialization. The other potential workarounds are to use a different name for the field (e.g. As a note of caution the CouchDB and Cloudant APIs do sometimes return the |
This limitation is now documented at https://github.com/IBM/cloudant-python-sdk/blob/main/KNOWN_ISSUES.md#name-collisions-with-reserved-metadata-fields |
This problem has been resolved in version |
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):
The text was updated successfully, but these errors were encountered: