sfackler / rust-postgres

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

Expose type modifier in Column struct #1145

Open SergeiPatiakin opened 6 months ago

SergeiPatiakin commented 6 months ago

What

Expose the 4-byte type-specific type modifier on the Column struct

Why

I would like access type modifiers for prepared statement columns. E.g. for a numeric column I would like to get the numeric precision and scale. For a varchar column I would like to get the varchar length limit.

Context

This is an extension of https://github.com/sfackler/rust-postgres/pull/1084 where other table and column OIDs were exposed in Column, and exposing type modifiers was noted as a possibility.

rishitesh-snt commented 2 months ago

+1 for this PR. This would enable the result set handling in a much better way rather than falling back to defaults. In fact, rather than type modifier, we should expose the derived precision & scale at the upper level API like Statement.