-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Export PgType
#1369
Comments
+1 I'm waiting this feature too. I tried to implement Type for my structure and I also need PgType. |
Yeah it is a really simple fix to make the type enums public instead of protected. Is there a good reason we only have access to the type via it's string name? |
This will be done but the main issue is how breaking a change it will be to change the type enumeration around before we stabilize it. We've tried to hide or make private most of the internal api for now because of not wanting to worry about making larger changes until we settle on a nice api. |
Just spent 30m trying to figure out what I was missing and finally landed here. With sufficient warning, I (and I think others) would prefer an unstable way to do this than no way or having to write extra fallible conversion boilerplate. Edit: I thought I could work around this somehow with oids but nope, those methods are pub(crate) too. I don't see any way to do this legitimately and I don't know the implications of using |
Found a workaround for producing the type info at least: for most types I think you can do |
Also voting for making this part of public API. I know that it's more about architecture decision than development effort, but will be able to help with dev part once architecture decision to make it public will be done. |
FWIW In my project I copied |
I have a similar use case where I need to know what the underlying PgType is. Even though PgValueRef exposes PgTypeInfo I can't do any comparisons on PgType because it's private. I could compare based on the PgTypeInfo::display_name but this seems to be brittle and I want to avoid it if possible. Up until now I was able to copy the PgTypeInfo code into my own repo and use the pg_catalog data to directly convert udt_name into a PgType but this doesn't work when detecting type names from the PgValueRef struct. |
+1 We would greatly benefit from this. |
This issue is to request exporting of the
PgType
enum from thepostgres
module.I'm struggling a bit with serializing rows from arbitrary queries to JSON. Ideally,
PgRow
s would have a convenient way of being serialized to JSON (even if you don't know the structure ahead of time). I haven't found a good way to do this, so instead I'm iterating over column metadata for each row and mapping the value to rust types according to the value's type_info per the documented type mappings. Unfortunately, I'm having to match against the.name()
of each type since it's the only public method that seems to be available for me to see the type.Deref
is implemented forPgTypeInfo
so I'm able to get aPgType
, but since the enum isn't exported by thepostgres
module I'm not able to match on it.The text was updated successfully, but these errors were encountered: