Skip to content
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

add databasetypename for time-with-time-zone #1883

Closed
gabor opened this issue Jan 22, 2024 · 3 comments
Closed

add databasetypename for time-with-time-zone #1883

gabor opened this issue Jan 22, 2024 · 3 comments

Comments

@gabor
Copy link

gabor commented Jan 22, 2024

Is your feature request related to a problem? Please describe.
i'm writing code that makes decisions based on the https://pkg.go.dev/database/sql#ColumnType.DatabaseTypeName.
the problem is:

  • for the postgres type time, it says TIME
  • for the postgres type time with time zone, it says 1266

i can hardcode 1266 into my code, but i feel something like TIMETZ would be better.

Describe the solution you'd like
return something better than 1266 for time-with-time-zone

Describe alternatives you've considered
i can just use the value "1266" instead.

@jackc
Copy link
Owner

jackc commented Jan 23, 2024

I suppose we could add some sort of support for it... But FYI, the PostgreSQL project itself recommends against using that type. From https://www.postgresql.org/docs/current/datatype-datetime.html:

The type time with time zone is defined by the SQL standard, but the definition exhibits properties which lead to questionable usefulness.

and later on the page

We do not recommend using the type time with time zone (though it is supported by PostgreSQL for legacy applications and for compliance with the SQL standard).

@gabor
Copy link
Author

gabor commented Jan 25, 2024

i see, thanks for the info. i still need to handle it in my use-case becaue of some legacy reasons, but i'll just go with the "1266". can i assume that that number will never change?

jackc added a commit that referenced this issue Jan 28, 2024
@jackc
Copy link
Owner

jackc commented Jan 28, 2024

That number is the OID assigned to the type in PostgreSQL. That will never change. The only way that would change in pgx is if pgx added some sort of support for timetz - then the name would change to timetz. I don't have any plans to do that, but if someone submitted a PR that added some sort of meaningful support I guess it could happen.

But for now I have added TimetzOID and TimetzArrayOID constants to pgtype so at least you can use a named constant.

@jackc jackc closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants