Parsing of timetz is not implemented.
The parsing of timetz is not implemented, in types/time.go there is no defined format for timetz. If
Expected Behavior
Parsing of a timetz column should not return an error.
Current Behavior
If the column is timetz, Select() returns an error: parsing time "16:06:09.123418+00": extra text: "+00"
Possible Solution
add timetzFormat to types/time.go
Steps to Reproduce
Code to reproduce the problem:
package main
import (
"time"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/orm"
)
type t struct {
ID int
Time time.Time `pg:",type:timetz"`
}
func main() {
db := pg.Connect(&pg.Options{
Addr: "localhost:5432",
Database: "test",
User: "postgres",
})
t1 := t{
ID: 1,
Time: time.Now(),
}
err := db.Model(&t1).CreateTable(&orm.CreateTableOptions{IfNotExists: true})
if err != nil {
panic(err)
}
_, err = db.Model(&t1).Insert()
if err != nil {
panic(err)
}
b := t{ID: t1.ID}
err = db.Model(&b).WherePK().Select()
if err != nil {
panic(err)
}
}
Context (Environment)
go version go1.15.6 linux/amd64 psql (PostgreSQL) 13.1 pg v10.7.3
Possible Implementation
In the current implementation of ParseTimeString the length is checking the length of the string to determine if it is a date or a datetime. The length of timetz can be a problem, maybe it would be better to use regex to determine the format.
It is unadvised to use timetz in postgresql, it is only implemented for SQL compliance. If you can you should use timestamptz, this works.