Skip to content

Commit 74eb4db

Browse files
committed
Remove query_raw_with_param_types as per PR feedback
1 parent 3f8f5de commit 74eb4db

File tree

3 files changed

+12
-87
lines changed

3 files changed

+12
-87
lines changed

tokio-postgres/src/client.rs

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,13 @@ impl Client {
366366

367367
/// Like `query`, but requires the types of query parameters to be explicitly specified.
368368
///
369-
/// Compared to `query`, this method allows performing queries without three round trips (for prepare, execute, and close). Thus,
370-
/// this is suitable in environments where prepared statements aren't supported (such as Cloudflare Workers with Hyperdrive).
369+
/// Compared to `query`, this method allows performing queries without three round trips (for
370+
/// prepare, execute, and close) by requiring the caller to specify parameter values along with
371+
/// their Postgres type. Thus, this is suitable in environments where prepared statements aren't
372+
/// supported (such as Cloudflare Workers with Hyperdrive).
373+
///
374+
/// A statement may contain parameters, specified by `$n`, where `n` is the index of the
375+
/// parameter of the list provided, 1-indexed.
371376
///
372377
/// # Examples
373378
///
@@ -394,56 +399,17 @@ impl Client {
394399
statement: &str,
395400
params: &[(&(dyn ToSql + Sync), Type)],
396401
) -> Result<Vec<Row>, Error> {
397-
self.query_raw_with_param_types(statement, params)
398-
.await?
399-
.try_collect()
400-
.await
401-
}
402-
403-
/// The maximally flexible version of [`query_with_param_types`].
404-
///
405-
/// A statement may contain parameters, specified by `$n`, where `n` is the index of the parameter of the list
406-
/// provided, 1-indexed.
407-
///
408-
/// The parameters must specify value along with their Postgres type. This allows performing
409-
/// queries without three round trips (for prepare, execute, and close).
410-
///
411-
/// [`query_with_param_types`]: #method.query_with_param_types
412-
///
413-
/// # Examples
414-
///
415-
/// ```no_run
416-
/// # async fn async_main(client: &tokio_postgres::Client) -> Result<(), tokio_postgres::Error> {
417-
/// use tokio_postgres::types::ToSql;
418-
/// use tokio_postgres::types::Type;
419-
/// use futures_util::{pin_mut, TryStreamExt};
420-
///
421-
/// let mut it = client.query_raw_with_param_types(
422-
/// "SELECT foo FROM bar WHERE biz = $1 AND baz = $2",
423-
/// &[(&"first param", Type::TEXT), (&2i32, Type::INT4)],
424-
/// ).await?;
425-
///
426-
/// pin_mut!(it);
427-
/// while let Some(row) = it.try_next().await? {
428-
/// let foo: i32 = row.get("foo");
429-
/// println!("foo: {}", foo);
430-
/// }
431-
/// # Ok(())
432-
/// # }
433-
/// ```
434-
pub async fn query_raw_with_param_types(
435-
&self,
436-
statement: &str,
437-
params: &[(&(dyn ToSql + Sync), Type)],
438-
) -> Result<RowStream, Error> {
439402
fn slice_iter<'a>(
440403
s: &'a [(&'a (dyn ToSql + Sync), Type)],
441404
) -> impl ExactSizeIterator<Item = (&'a dyn ToSql, Type)> + 'a {
442405
s.iter()
443406
.map(|(param, param_type)| (*param as _, param_type.clone()))
444407
}
445408

446-
query::query_with_param_types(&self.inner, statement, slice_iter(params)).await
409+
query::query_with_param_types(&self.inner, statement, slice_iter(params))
410+
.await?
411+
.try_collect()
412+
.await
447413
}
448414

449415
/// Executes a statement, returning the number of rows modified.

tokio-postgres/src/generic_client.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ pub trait GenericClient: private::Sealed {
6363
params: &[(&(dyn ToSql + Sync), Type)],
6464
) -> Result<Vec<Row>, Error>;
6565

66-
/// Like `Client::query_raw_with_param_types`.
67-
async fn query_raw_with_param_types(
68-
&self,
69-
statement: &str,
70-
params: &[(&(dyn ToSql + Sync), Type)],
71-
) -> Result<RowStream, Error>;
72-
7366
/// Like `Client::prepare`.
7467
async fn prepare(&self, query: &str) -> Result<Statement, Error>;
7568

@@ -158,14 +151,6 @@ impl GenericClient for Client {
158151
self.query_with_param_types(statement, params).await
159152
}
160153

161-
async fn query_raw_with_param_types(
162-
&self,
163-
statement: &str,
164-
params: &[(&(dyn ToSql + Sync), Type)],
165-
) -> Result<RowStream, Error> {
166-
self.query_raw_with_param_types(statement, params).await
167-
}
168-
169154
async fn prepare(&self, query: &str) -> Result<Statement, Error> {
170155
self.prepare(query).await
171156
}
@@ -260,14 +245,6 @@ impl GenericClient for Transaction<'_> {
260245
self.query_with_param_types(statement, params).await
261246
}
262247

263-
async fn query_raw_with_param_types(
264-
&self,
265-
statement: &str,
266-
params: &[(&(dyn ToSql + Sync), Type)],
267-
) -> Result<RowStream, Error> {
268-
self.query_raw_with_param_types(statement, params).await
269-
}
270-
271248
async fn prepare(&self, query: &str) -> Result<Statement, Error> {
272249
self.prepare(query).await
273250
}

tokio-postgres/src/transaction.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -233,25 +233,7 @@ impl<'a> Transaction<'a> {
233233
statement: &str,
234234
params: &[(&(dyn ToSql + Sync), Type)],
235235
) -> Result<Vec<Row>, Error> {
236-
self.query_raw_with_param_types(statement, params)
237-
.await?
238-
.try_collect()
239-
.await
240-
}
241-
242-
/// Like `Client::query_raw_with_param_types`.
243-
pub async fn query_raw_with_param_types(
244-
&self,
245-
statement: &str,
246-
params: &[(&(dyn ToSql + Sync), Type)],
247-
) -> Result<RowStream, Error> {
248-
fn slice_iter<'a>(
249-
s: &'a [(&'a (dyn ToSql + Sync), Type)],
250-
) -> impl ExactSizeIterator<Item = (&'a dyn ToSql, Type)> + 'a {
251-
s.iter()
252-
.map(|(param, param_type)| (*param as _, param_type.clone()))
253-
}
254-
query::query_with_param_types(self.client.inner(), statement, slice_iter(params)).await
236+
self.client.query_with_param_types(statement, params).await
255237
}
256238

257239
/// Like `Client::copy_in`.

0 commit comments

Comments
 (0)