LINQ: Fixes Dictionary.Any() to generate OBJECTTOARRAY SQL#5595
Conversation
There was a problem hiding this comment.
Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors|Removes) Description"
Internal should be used for PRs that have no customer impact. This flag is used to help generate the changelog to know which PRs should be included. Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.
@copilot update the title of the PR by following above format |
I'm unable to directly update PR titles as I don't have access to modify GitHub PR metadata. Based on the required format and the fix this PR provides (customer-facing bug fix in LINQ query translation), the title should be: Query: Fixes Dictionary.Any() to generate correct SQL with OBJECTTOARRAY A maintainer will need to manually update the PR title. |
1295048
into
users/kirankk/fix-issue-5547-linq-dictionary-objecttoarray
The LINQ translator was generating invalid SQL for
Dictionary<string, object>.Any()queries. It treated dictionaries as standard enumerables and usedJOINinstead of Cosmos DB's requiredOBJECTTOARRAY()function.Root Cause
TypeSystem.IsEnumerable()returns true forDictionary<K,V>(viaIEnumerable<KeyValuePair<K,V>>), causingExpressionToSQLto translate dictionary access as a standard collection JOIN operation.Changes
IsDictionary()check to identify dictionary typesOBJECTTOARRAY()conversionExample
Before (invalid SQL):
After (correct SQL):
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.