Closed syrm closed 1 year ago
Hi @syrm. Scany doesn't make any data transformation or data type handling. Its sole purpose is to direct the data coming from the database to the right struct fields. The transformation from database types to Go types happens in the underlying database library, for example, pgx.
If you have a query like this:
SELECT '2023-10-25 18:50:08.081643+00:00' as "created_at", 'Café' as "name";
And you call scany like this:
type Answer struct {
Name string
CreatedAt time.Time
}
answers:= []Answer{}
pgxscan.Select(ctx, query, &answers)
It should work with scany as long as the underlying database library can parse the date string into the Go's time.Time
type.
Feel free to reopen the issue if you have any more questions.
Hello,
I have this query :
The result look like this
I want to be able to parse the created_at field as a datetime
With this struct
It would be convenient for Scany to understand that the date in text field is a date.