-
Notifications
You must be signed in to change notification settings - Fork 871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pgtype.Time
doesn't parse time with time zone
properly
#1940
Comments
pgtype.Time
doesn't parse times with time zone
types properlypgtype.Time
doesn't parse times with time zone
properly
pgtype.Time
doesn't parse times with time zone
properlypgtype.Time
doesn't parse time with time zone
properly
Looking at the types in There is also a bug in the string parsing of Overall both things should be easy to solve. @jackc If you have no further comments I would implement this on the weekend. |
@felix-roehrich I suppose stricter parsing for I'm not especially enthusiastic about adding From https://www.postgresql.org/docs/current/datatype-datetime.html:
and
It's not even clear to me exactly what the Go type would look like. |
I have thought about this myself. On the one hand it is still part of the SQL standard, on the other hand it is clearly used very rarely (otherwise this issue would have been reported long ago). |
Making parsing stricter on |
Describe the bug
When using
pgtype.Time
to parse atime with time zone
column that has been retrieved from a Postgres database the time zone offset ends up being used as the resulting fractional seconds.To Reproduce
Insert time data into Postgres to verify string output:
Outputs values:
Then try to parse any of these values with
pgtype.Time.Scan()
:Expected behavior
Either the time zone offset should be ignored
01:34:17.000000
, a parsing error should be thrown, or the offset should be applied to the time05:34:17.000000
.Actual behavior
Note the .04
Version
go version go1.22.0 darwin/arm64
PostgreSQL 16.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
github.com/jackc/pgx/v5 v5.5.4
The text was updated successfully, but these errors were encountered: