sfackler / rust-postgres

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

Expose SimpleQueryRow internals to user #950

Open dfwilbanks395 opened 2 years ago

dfwilbanks395 commented 2 years ago

I have a use case where I'd like to reconstruct a Simple Query message and pass it back to my user. To do this I'd want to make a few changes to the Client::simple_query() implementation.

  1. Store and return the entire Field that is built from a backend Message::RowDescription in SimpleQueryRow instead of just returning the column name in SimpleColumn. I've done this with minor changes to the current interface in our rust-postgres fork.

  2. Ideally, expose SimpleQueryRow::body to avoid having to read each value using SimpleQueryRow::get() and re-serialize the message to bytes myself.

  3. Ideally, create public constructors for SimpleQueryRow, Field, and DataRowBody to allow easier unit testing in my own code. I noticed that a similar question came up in a previous issue. Maybe we could implement this under a compile time feature flag?