azure-sdk-for-java
azure-sdk-for-java copied to clipboard
[BUG] SqlQuerySpec datetime inequality returns no results
Describe the bug When a SqlQuerySpec issues a query containing a datetime string inequality the query returns no results even when it would be expected. Queries which bypass SqlQuerySpec and utilize only a query string return the expected number of results.
Exception or Stack Trace Add the exception log and stack trace if available
No exception, the query returns zero results.
To Reproduce Steps to reproduce the behavior:
See Code Snippet.
Code Snippet Add the code snippet that causes the issue.
A query employing SqlQuerySpec to issues a query containing a datetime string inequality will reproduce the error:
String queryText = "SELECT * FROM ROOT r WHERE r.id = @name AND r.projectStartDate = @projectDate";
List<SqlParameter> paramList = new ArrayList<>();
paramList.add(new SqlParameter("@name", "ContosoInternal")); paramList.add(new SqlParameter("@projectDate", "2018-01-06T19:21:27.0000000Z"));
However, the error will not occur if the query is issued directly as a string bypassing SqlQuerySpec:
"SELECT * FROM ROOT r WHERE r.id = 'ContosoInternal' AND r.projectStartDate = '2018-01-06T19:21:27.0000000Z'";
For reference, here is the JSON datamodel utilized in these tests (the partition key is projectStartDate):
{
"id": "SannyRicssonEntertainmentProject",
"projectManager": "Leif Carlson",
"projectStartDate": "2020-05-05T19:21:27.0000000Z",
"_rid": "GU1TALwMZZEBAAAAAAAACA==",
"_self": "dbs/GU1TAA==/colls/GU1TALwMZZE=/docs/GU1TALwMZZEBAAAAAAAACA==/",
"_etag": "\"0000b800-0000-0700-0000-5f96c6400000\"",
"_attachments": "attachments/",
"_ts": 1603716672
}
Expected behavior The SqlQuerySpec query should perform exactly as the direct query string does.
Screenshots If applicable, add screenshots to help explain your problem.
N/A
Setup (please complete the following information):
- OS: Windows
- IDE : Intellij
- Version of the Library used: 4.8.0
Additional context This issue was found in the context of testing Spring Data Azure Cosmos DB, which consumes Azure Cosmos DB Java SDK 4.x.x
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- [x ] Bug Description Added
- [ x] Repro Steps Added
- [ x] Setup information Added
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @kushagraThapar, @anfeldma-ms
@mbhaskar - any updates on this issue ?
@anfeldma-ms any updates on this? This has been open for some time so has it been resolved with newer versions of the SDK?