-
Notifications
You must be signed in to change notification settings - Fork 299
Closed
Labels
CosmosThe azure_cosmos crateThe azure_cosmos cratecustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.
Description
Bug Title
read_item
returns empty body while query_items
succeeds
Crate Name
azure_data_cosmos
Crate Version
v0.26.0
Description
I am able to query an item with query_item
but not with read_item
. Can you help me understand why read_item
is not working? Also, why does query_items not support setting a session token as the other operations do.
Steps to Reproduce
I have the following item:
#[derive(Serialize, Deserialize)]
struct Item {
pub id: String,
pub foo: String, // partition key
pub value: String,
}
The following successfully inserts the item but fails to read. When i inspected the http body, it returns empty but with a 200 response.
async fn example(container: &ContainerClient) -> anyhow::Result<()> {
let item = Item {
id: "1".into(),
foo: "partition1".into(),
value: "2".into(),
};
// Create an item
container.upsert_item("partition1", item, None).await?;
// Read an item
let item_response = container.read_item("partition1", "1", None).await?;
let mut item: Item = item_response.into_body().await?; // FAILS TO MARSHALL OBJECT HERE AS BODY IS EMPTY
println!("Item: {:#?}", item.value);
item.value = "4".into();
Ok(())
}
While the following succeeds
async fn example_with_query(container_client: &ContainerClient) -> anyhow::Result<()> {
let id = "1".into();
let resp = container_client
.query_items::<Item>(format!("SELECT * FROM c WHERE c.id='{id}'"), "partition1".to_string(), None)
.context("failed to query item")?;
let mut stream = resp.into_stream();
match stream.try_next().await {
Err(e) => {
eprintln!("Error reading item: {}", e);
return Err(anyhow::anyhow!("Failed to read item"));
}
Ok(None) => {
println!("Item not found");
return Ok(());
},
Ok(Some(item)) => {
println!("Item found: {:#?}", item);
}
}
Ok(())
}
Can you help me understand why read_item
is not working? Also, why does query_items not support setting a session token as the other operations do.
Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
CosmosThe azure_cosmos crateThe azure_cosmos cratecustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.
Type
Projects
Status
Done