PlagueHO / CosmosDB

PowerShell Module for working with Azure Cosmos DB databases, collections, documents, attachments, offers, users, permissions, triggers, stored procedures and user defined functions.
http://dscottraynsford.com
MIT License
154 stars 46 forks source link

New-CosmosDbDocument does not allow create records with key names differ by case only #413

Closed alexeymarkov closed 3 years ago

alexeymarkov commented 3 years ago

It is not possible to add records where key names differ by case only. For example, { "key": "value", "Key": "Value" } although this is a valid Cosmos Db document.

The problem is at line ConvertFrom-Json

PlagueHO commented 3 years ago

Thanks for raising this @alexeymarkov.

To fix this I might need to implement additional functions for just passing/returning raw JSON payloads instead of converting them to/from objects. Being .NET objects these can't have duplicate key names. Therefore we'd need to support not performing any JSON -> Object conversion.

E.g. New-CosmosDbDocumentJson Set-CosmosDbDocumentJson

The Get-CosmosDbDocumentJson function already exists to address this problem.

I'll work on this tomorrow.

PlagueHO commented 3 years ago

Further on thinking on this, I might just add a -ReturnJson switch to the functions instead and document the purpose is to allow for this condition.