sfackler / rust-postgres

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

Work with pools that don't support prepared statements #1147

Closed ramnivas closed 4 days ago

ramnivas commented 1 month ago

Introduce a new query_with_param_types method that allows to specify Postgres type parameters. This obviated the need to use prepared statements just to obtain parameter types for a query. It then combines parse, bind, and execute in a single packet.

Related: #1017, #1067

sfackler commented 1 week ago

Thinking about it, it seems like we could make query_typed do this when invoked with a non-prepared statement instead of adding a new method.

ramnivas commented 1 week ago

Thinking about it, it seems like we could make query_typed do this when invoked with a non-prepared statement instead of adding a new method.

Did you mean prepare_typed (there is no query_typed). One nice thing about the new query_with_param_types is that it takes param values and param types through tuples, so the client cannot specify fewer (or more) types than parameter length.

sfackler commented 1 week ago

Did you mean prepare_typed (there is no query_typed).

Ah yeah my idea didn't really make much sense :D

sfackler commented 1 week ago

Let's rename the method to query_typed, which aligns with prepare_typed and is a bit shorter.

ramnivas commented 1 week ago

Let's rename the method to query_typed, which aligns with prepare_typed and is a bit shorter.

Done!

sfackler commented 1 week ago

LGTM but there's one small clippy error to fix.

ramnivas commented 1 week ago

LGTM but there's one small clippy error to fix.

Fixed.

sfackler commented 4 days ago

Thanks!

ramnivas commented 4 days ago

Thanks!

Thank you!