sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.42k stars 436 forks source link

Add table_oid and column_id to column structure of prepared statements #1084

Closed bikeshedder closed 8 months ago

bikeshedder commented 8 months ago

I want to access the underlying table and column of a query and found those two information not exposed in the statement::Column structure.

I also simplified the Debug implementation of Column by using r#type rather than type_ so #[derive(Debug)] can be used. As the argument list grew longer I also removed the new method in favor of making all the fields pub(crate).

Should we maybe expose the three remaining fields as well?

I don't have an immediate need for them. They could provide useful in the future, though.

What are your thoughts on using NonZeroU32 and NonZeroI16? I'm not 100% sure if that's really a good choice for the type. Yet it felt somewhat natural to use it as 0 denotes that this information is not available.

bikeshedder commented 8 months ago

@sfackler Sorry for bothering you. Is there a chance this PR could be merged soon? I'm in need of this feature for an upcoming code generation tool for type safe queries based on tokio-postgres.

sfackler commented 8 months ago

Thanks! Sorry for the delay.

sfackler commented 8 months ago

Hmm, actually I think I'm going to adjust the return values to Option<u32> rather than use NonZeroU32. That's what we use elsewhere in the API.

bikeshedder commented 7 months ago

@sfackler Is there a chance you could release a new tokio-postgres version. I'm in progress of releasing a crate that does depend on this feature. I can't push this to crates.iounless a new version of tokio-postgres is published first.

I plan on releasing my crate in 1-2 weeks so a release of tokio-postgres would be highly appreciated.