@@ -366,8 +366,13 @@ impl Client {
366
366
367
367
/// Like `query`, but requires the types of query parameters to be explicitly specified.
368
368
///
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.
371
376
///
372
377
/// # Examples
373
378
///
@@ -394,56 +399,17 @@ impl Client {
394
399
statement : & str ,
395
400
params : & [ ( & ( dyn ToSql + Sync ) , Type ) ] ,
396
401
) -> 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 > {
439
402
fn slice_iter < ' a > (
440
403
s : & ' a [ ( & ' a ( dyn ToSql + Sync ) , Type ) ] ,
441
404
) -> impl ExactSizeIterator < Item = ( & ' a dyn ToSql , Type ) > + ' a {
442
405
s. iter ( )
443
406
. map ( |( param, param_type) | ( * param as _ , param_type. clone ( ) ) )
444
407
}
445
408
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
447
413
}
448
414
449
415
/// Executes a statement, returning the number of rows modified.
0 commit comments