Prisma1: Go client: map DateTime to time.Time

Created on 21 Feb 2019  Â·  9Comments  Â·  Source: prisma/prisma1

Describe the bug
DateTime is currently mapped to a string.
It would be nice if DateTime could map to time.Time, or maybe rather add a new type which maps to date for backwards compatibility and people who want to use a string.

// date has to be converted to string first
date := time.Now().String()

user, err := r.Prisma.Users(&prisma.UsersParams{
    Where: &prisma.UserWhereInput{
        CreatedAt: &date,
    },
}).Exec(ctx)
kinfeature arecliengo

Most helpful comment

I just think that dates should map to the native type in each language, which would be time.Time for Go and Date for JS.

When I understood correctly, you're asking on how to handle unprovided values for a date, e.g. when only providing a year. It would make sense to just map the missing values to zeros, e.g. Date('2019-02-23') becomes 2019-02-23T00:00:00.000Z internally.

All 9 comments

cc @dominikh

How do the other clients handle the fact that DateTime can represent different levels of precision? That is, it can be just a year, year + month, and so on up to a full date + time + timezone. Are they all mapped to an ordinary DateTime type with default values for the missing components, or do we track which values were provided?

As for

or maybe rather add a new type which maps to date for backwards compatibility

I think the Go generator is new enough that consistency is more important than backwards compatibility?

I just think that dates should map to the native type in each language, which would be time.Time for Go and Date for JS.

When I understood correctly, you're asking on how to handle unprovided values for a date, e.g. when only providing a year. It would make sense to just map the missing values to zeros, e.g. Date('2019-02-23') becomes 2019-02-23T00:00:00.000Z internally.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

I think this is an important issue – could someone please remove the stale status as well as the specific go label? This issue applies to all clients.
[edit: well, that worked)

@matthewmueller

Is this something that we can consider in the new Go client spec?

https://github.com/matthewmueller/rfcs/blob/new-go-client-rfc/text/0000-go-client.md

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

Yes, this is something we'd like to support in the next release of Prisma :-)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marktani picture marktani  Â·  3Comments

sedubois picture sedubois  Â·  3Comments

ragnorc picture ragnorc  Â·  3Comments

notrab picture notrab  Â·  3Comments

hoodsy picture hoodsy  Â·  3Comments