dotnet-sdk
dotnet-sdk copied to clipboard
Query State is not working with cockroachDB and .net Dapr Client
Expected Behavior
Query should retrieve the stored record.
Actual Behavior
Query doe not return any records.
Steps to Reproduce the Problem
Store the state as below
string id = "2"; // Guid.NewGuid().ToString();
string key = $"Api-{tenant}-{id}";
var api = new a {
b = "c"
};
await _daprClient.SaveStateAsync<a>(StoreName, key, api);
await _daprClient.SaveStateAsync<string>(StoreName, "2b", JsonSerializer.Serialize(api));
Retrieving state works fine:
var x = (await _daprClient.GetStateAsync<a>(StoreName, "Api--2"));
However, query state always return no record:
var q = "{" +
"\"filter\": {" +
"\"EQ\": { \"value.b\": \"c\" }" +
"}" +
"}";
//var q = "{" +
// "\"filter\": {" +
// "\"EQ\": { \"b\": \"c\" }" +
// "}" +
//"}";
var queryResponse = await _daprClient.QueryStateAsync<a>(StoreName, q);
foreach (var entry in queryResponse.Results)
{
Console.WriteLine($"value: {entry.Data.b}");
}
The data stored in database is binary:
key | value | isbinary | etag | insertdate | updatedate
--------------------------+------------------------------------------------+----------+------+-------------------------------+--------------------------------
api-manager-api||2b | "IntcdTAwMjJiXHUwMDIyOlx1MDAyMmNcdTAwMjJ9Ig==" | true | 2 | 2022-09-13 18:58:40.340341+00 | 2022-09-13 19:01:44.954366+00
api-manager-api||Api--1 | "eyJiIjoiYyJ9" | true | 1 | 2022-09-13 18:23:42.650024+00 | NULL
api-manager-api||Api--2 | "eyJiIjoiYyJ9" | true | 2 | 2022-09-13 18:58:40.265943+00 | 2022-09-13 19:01:43.017007+00`
(3 rows)
I managed to store the json into cockroachDB but the query with EQ: {"b", "c" } or EQ: {"value.b", "c"} still returns nothing.
key | value | isbinary | etag | insertdate | updatedate
---------------------------+------------------------------------------------+----------+------+-------------------------------+--------------------------------
api-manager-api||123 | "eyJiIjoiYyJ9" | true | 2 | 2022-09-13 21:31:30.087913+00 | 2022-09-13 21:48:09.140251+00
api-manager-api||2b | "IntcdTAwMjJiXHUwMDIyOlx1MDAyMmNcdTAwMjJ9Ig==" | true | 2 | 2022-09-13 18:58:40.340341+00 | 2022-09-13 21:48:09.114109+00
api-manager-api||444 | "IntcdTAwMjJiXHUwMDIyOlx1MDAyMmNcdTAwMjJ9Ig==" | true | 2 | 2022-09-13 21:37:57.557071+00 | 2022-09-13 21:48:09.150479+00
api-manager-api||Api--1 | "eyJiIjoiYyJ9" | true | 1 | 2022-09-13 18:23:42.650024+00 | NULL
api-manager-api||Api--2 | "eyJiIjoiYyJ9" | true | 2 | 2022-09-13 18:58:40.265943+00 | 2022-09-13 21:48:09.072631+00
api-manager-api||order_3 | "eyJiIjoiYyJ9" | true | 2 | 2022-09-13 21:01:16.154948+00 | 2022-09-13 21:19:28.855963+00
api-manager-api||test1 | "{\\"b\\":\\"c\\"}" | false | 1 | 2022-09-13 21:48:09.160417+00 | NULL
(7 rows)