Google-cloud-go: datastore: support civil.Date for properties

Created on 27 Oct 2020  路  6Comments  路  Source: googleapis/google-cloud-go

Is your feature request related to a problem? Please describe.
We sometimes store dates-without-location (in the sense of the civil package) in datastore. Sadly, that means we have to handle them, temporarily at least, as time.Time. This is sort of a foot-gun for all the usual reasons (described, for example, in e.g. golang/go#19700).

Describe the solution you'd like
We could have a struct-field of type civil.Date; that way we never have to have a time.Time-representing-a-civil-date floating around. Ideally this would be compatible with how the libraries in other languages, some of which have a date-property, do things.

Describe alternatives you've considered
We could write a PropertyLoadSaver for each such model, and specially handle the field. That's definitely possible but it's some extra work for each such model.

datastore feature request

All 6 comments

This seems like a good thing to add support for. @IlyaFaer could you take this one? The civil package is cloud.google.com/go/civil .

@tritone, sure, I'll take a look.

We've merged this change. @benjaminjkraft would it be possible for you to test this for your purposes at HEAD before we cut a release?

Sure! Let me follow up with @miguelcastillo and/or @dnerdy but I think we should be able to pull this in and get some testing soon. Thanks much for implementing this, it will definitely simplify some things for us!

@tritone It looks like there's a bug. I've left a comment with details on #3202.

I've opened a separate issue for the bug: #3360.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

deelienardy picture deelienardy  路  3Comments

junghoahnsc picture junghoahnsc  路  4Comments

alxmsl picture alxmsl  路  4Comments

dragan-cikic-shortcut picture dragan-cikic-shortcut  路  3Comments

imkira picture imkira  路  4Comments