lib / pq

Pure Go Postgres driver for database/sql
https://pkg.go.dev/github.com/lib/pq
MIT License
9.12k stars 911 forks source link

What would it take to support the Interval Type in lib/pq? #710

Closed lrosenman closed 6 years ago

lrosenman commented 6 years ago

I have a go library for the AmbientWeather.net API, and I write those responses to a PostgreSQL database. One of the fields returned is time.Duration which I was putting into an interval field.

In order to satisfy pq, I had to fmt.Sprintf("%v",time.DurationField).

I was wondering if there was any objection to my trying to hack/add support for interval/duration support into this library.

cbandy commented 6 years ago

They aren't exactly compatible. See discussion in #78.

To control how sql.DB interprets a type, implement the driver.Valuer interface.

lrosenman commented 6 years ago

Thanks. I hadn't done much research, and in my case, I'm just dealing with milliseconds from a response time call (see https://github.com/lrosenman/ambient in the API*.ResponseTime fields).

Thanks!