mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-05-19 11:47:31 +01:00
Added quote escaping for partition key extraction (#2403)
This commit is contained in:
@@ -249,4 +249,27 @@ export const documentTestCases: DocumentTestCase[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Single Double-Quoted Partition Key",
|
||||
databaseId: "e2etests-sql-readonly",
|
||||
containerId: "doubleQuotedPartitionKey",
|
||||
documents: [
|
||||
{
|
||||
documentId: "doubleQuotedPartitionKey",
|
||||
partitionKeys: [{ key: "/partition-key", value: "doubleQuotedValue" }],
|
||||
},
|
||||
{
|
||||
documentId: "doubleQuotedPartitionKey_empty_string",
|
||||
partitionKeys: [{ key: "/partition-key", value: "" }],
|
||||
},
|
||||
{
|
||||
documentId: "doubleQuotedPartitionKey_null",
|
||||
partitionKeys: [{ key: "/partition-key", value: null }],
|
||||
},
|
||||
{
|
||||
documentId: "doubleQuotedPartitionKey_missing",
|
||||
partitionKeys: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
+8
-1
@@ -251,7 +251,14 @@ export const setPartitionKeys = (partitionKeys: PartitionKey[]) => {
|
||||
partitionKeys.forEach((partitionKey) => {
|
||||
const { key: keyPath, value: keyValue } = partitionKey;
|
||||
const cleanPath = keyPath.startsWith("/") ? keyPath.slice(1) : keyPath;
|
||||
const keys = cleanPath.split("/");
|
||||
const keys = cleanPath.split("/").map((segment) => {
|
||||
// Strip enclosing double quotes from partition key path segments
|
||||
// e.g., '"partition-key"' -> 'partition-key'
|
||||
if (segment.length >= 2 && segment.charAt(0) === '"' && segment.charAt(segment.length - 1) === '"') {
|
||||
return segment.slice(1, -1);
|
||||
}
|
||||
return segment;
|
||||
});
|
||||
let current = result;
|
||||
|
||||
keys.forEach((key, index) => {
|
||||
|
||||
Reference in New Issue
Block a user