Fixes issue when CRUD with no parition key for all APIs (#1362)

* Fixes issue where empty partition key is treated like nonexistent key for Tables API

* Updated format

* Refactor fix

* Prettier

* Fixes issue when CRUD with no parition key for all APIs

* Format fix

* Refactor to explicitly check for Tables
This commit is contained in:
vchske
2022-12-13 11:36:39 -08:00
committed by GitHub
parent 950c8ee470
commit 2f32a676d0
4 changed files with 18 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import { HttpHeaders } from "../Constants";
import { client } from "../CosmosClient";
import { getEntityName } from "../DocumentUtility";
import { handleError } from "../ErrorHandlingUtils";
import { getPartitionKeyValue } from "./getPartitionKeyValue";
export const readDocument = async (collection: CollectionBase, documentId: DocumentId): Promise<Item> => {
const entityName = getEntityName();
@@ -21,7 +22,7 @@ export const readDocument = async (collection: CollectionBase, documentId: Docum
const response = await client()
.database(collection.databaseId)
.container(collection.id())
.item(documentId.id(), documentId.partitionKeyValue?.length === 0 ? "" : documentId.partitionKeyValue)
.item(documentId.id(), getPartitionKeyValue(documentId))
.read(options);
return response?.resource;