sfackler / rust-postgres

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

Using named arguments in queries using the `pg_named_args` crate #1107

Open rudolphfroger opened 7 months ago

rudolphfroger commented 7 months ago

Hi,

Thanks for all the work on rust-postgres!

We've created a new crate which allows one to use named arguments on queries. This is achieved using a macro which rewrites the named arguments into positional arguments. This crate is specifically aimed at supporting rust-postgres because it outputs the query and array exactly as needed.

This crate happily lives on it's own, but it may be nice to point people towards the possibility of using named arguments in the tokio-postgres documentation. Would you be willing to add such a reference to your documentation and/or README?

The docs can be found at: https://docs.rs/pg_named_args/. This includes some examples on how to use it. We've been using this internally for some time, and it works great for us, especially once you have more than a few arguments.

sfackler commented 6 months ago

Neat! Sure, it seems reasonable to link to it in the crate docs.