Describe the bug
LINQ document queries with decimal type at where clause causes Specified cast is not valid exception. This kind of behavior started from client version 2.2.0.
To Reproduce
Complete demo console application to reproduce this issue: https://github.com/tapiou/cosmos-db-issue-demo
client = new DocumentClient(new Uri(endpointUrl), authorizationKey);
var uri = UriFactory.CreateDocumentCollectionUri(databaseId, collectionId);
var rows = client.CreateDocumentQuery<DocumentModel>(uri, feedOptions)
.Where(i => i.amount < 0m)
.ToList();
Above code snippets throws Specified cast is not valid exception. If I downgrade client version below 2.2.0 that code will run as expected without errors.
Also I noticed that if I change amount's type from decimal to double or float, it would also work without exceptions.
Expected behavior
Query would successfully ran without exception
Actual behavior
Query throws Specified cast is not valid exception
Environment summary
SDK Version: 2.2.1
OS Version: W10
Additional context
Stack trace
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at Microsoft.Azure.Documents.Linq.DocumentQuery`1.<GetEnumerator>d__31.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at CosmosDemo.Program.Main(String[] args) in C:\\Users\\*\\source\\repos\\CosmosDemo\\CosmosDemo\\Program.cs:line 41
We are seeing exactly the same issue.
This is the case for us, too. Please fix it, because it is a serious issue.
Edit: Confirmed that downgrading to 2.1.3 solves the issue.
This is still an issue in 2.2.2. Please fix because half of our data is Decimal.
Same issue here. It's kind of annoying.
This is still an issue in 2.2.3. This makes the updates since 2.1.3 unusable for people who are working with decimals and I think this is a not just a few people.
@bchong95 can you take a look?
Having the exact same issue using 2.3.0. ETA on fix?
We have the fix for this. We will try to release it in the next few days.
I'm working on a fix - it may take a bit longer but we'll target for the soonest release.
This is fixed in the latest release 2.4.0. Thanks.
Most helpful comment
This is fixed in the latest release 2.4.0. Thanks.