Skip to content
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

Get-CosmosDbDocument -QueryParameters hashtable array is case sensitive #446

Open
Szeraax opened this issue Oct 21, 2021 · 2 comments · May be fixed by #447
Open

Get-CosmosDbDocument -QueryParameters hashtable array is case sensitive #446

Szeraax opened this issue Oct 21, 2021 · 2 comments · May be fixed by #447
Labels
bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community.

Comments

@Szeraax
Copy link

Szeraax commented Oct 21, 2021

I have to do lower case name and value keys in each hashtable.

If I do upper case NAME, I get the error:

Invalid query. Specified parameterized query JSON is malformed

If I do upper case VALUE, I get no results.

Will start digging into code shortly.

@Szeraax
Copy link
Author

Szeraax commented Oct 21, 2021

Ok, so this cmdlet just passes through the hashtable directly as seen here:

$bodyObject += @{ parameters = $QueryParameters }

Here is a proof of concept for what would need done to translate parameters to always be lower case:

$QueryParameters = $QueryParameters | %{
  $ht = @{}
  $_.getenumerator() | %{
    $ht.add($_.Name.ToLower(),$_.Value)
  }
  $ht
}

I'd expect the performance hit to be quite minimal if implemented. Alternatively, it could be nice to check if the hashtable array contains any name or value keys that aren't fully lower case and error if so. Thoughts on what direction you'd like to go?

@PlagueHO
Copy link
Owner

Hi @Szeraax - ah yes, I see what you mean. It doesn't specifically call this out in the docs (https://docs.microsoft.com/en-us/rest/api/cosmos-db/query-documents), but makes sense. The fix makes sense, but just would need slight style adjustments. What I'd also suggest is moving the whole code block to a helper function that we can put unit tests on (just makes testing easier). Happy to do this or take a PR if you want?

@PlagueHO PlagueHO added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. labels Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants