Datastore query projection with datetime returns integer
See original GitHub issueI have datetime type in my projection and it returns me integer value instead of timestamp value. If I remove the datetime type from projection, I get correct type back. Below is sample query -
Query query = new Query(historical)
{
Filter = filter,
Projection = { stocksymbol, date },
DistinctOn = { stocksymbol },
Order = {
{ stocksymbol, PropertyOrder.Types.Direction.Descending },
{ date, PropertyOrder.Types.Direction.Descending }
}
};
var queryResult = await dataStore.RunQueryAsync(query);
queryResult.Entities.Properties[date] return back Integer value.
I read about similar issue here (https://github.com/googleapis/google-cloud-node/issues/1319) and the workaround given is not working for me.
This is my modified code with the workaround but I still get incorrect date:
var result = new DateTime(Convert.ToInt64(x.Properties[date].IntegerValue.ToString(), 10) / 1000)
Any ideas what I am missing or how do i fix this issue?
Issue Analytics
- State:
- Created 5 years ago
- Comments:17
Top Results From Across the Web
Google Cloud Datastore date field getting converted ...
Date and time value, returned as part of a projection query, is being converted by the Datastore mode to microsecond integer values.
Read more >Datastore Queries
The query can return entire entities, projected entities, or just entity keys. A typical query includes the following: An entity kind to which...
Read more >Projection Queries - Google Cloud Datastore - huihoo
The query returns abridged results with only the specified properties ( name , email , and phone in the example) populated with values;...
Read more >Queries — google-cloud 0.20.0 documentation - Read the Docs
Create / interact with Google Cloud Datastore queries. ... Limit the number of results returned. offset (integer) – (Optional) Offset used to begin...
Read more >google.cloud.ndb.model — ndb documentation
"""Model classes for datastore objects and properties for models. ... Iterating over a Query object returns the entities matching the query one at...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Thaina: That would only work with an integer number of seconds or milliseconds (we go down to microseconds) - and isn’t available in the frameworks we target. (So it could be in client code, but not in our libraries.)
@Thaina: But
DateTimeOffset.FromUnixTimeSeconds
doesn’t exist on every platform that we target, so we just can’t use it.Likewise,
TimeSpan.FromMilliseconds
isn’t terribly useful when we have a value in microseconds and we don’t want to lose that precision.I’m entirely comfortable with the implementation we’ve got, and it’s only an implementation detail anyway.