Skip to content

Commit 0186281

Browse files
committed
Add Debug bound on ToSql and log params during stmt execution
1 parent 8c6f72d commit 0186281

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use std::borrow::{ToOwned, Cow};
6565
use std::cell::{Cell, RefCell};
6666
use std::collections::{VecDeque, HashMap};
6767
use std::fmt;
68-
use std::iter::{IntoIterator, RandomAccessIterator};
68+
use std::iter::IntoIterator;
6969
use std::io::{self, BufStream};
7070
use std::io::prelude::*;
7171
use std::mem;
@@ -1353,7 +1353,7 @@ impl<'conn> Statement<'conn> {
13531353
"expected {} parameters but got {}",
13541354
self.param_types.len(),
13551355
params.len());
1356-
debug!("executing statement {}", self.name);
1356+
debug!("executing statement {} with parameters: {:?}", self.name, params);
13571357
let mut values = vec![];
13581358
for (param, ty) in params.iter().zip(self.param_types.iter()) {
13591359
let mut buf = vec![];
@@ -2032,7 +2032,7 @@ impl<'a> CopyInStatement<'a> {
20322032
where I: Iterator<Item=J>, J: StreamIterator {
20332033
let mut conn = self.conn.conn.borrow_mut();
20342034

2035-
debug!("executing statement {}", self.name);
2035+
debug!("executing COPY IN statement {}", self.name);
20362036
try!(conn.write_messages(&[
20372037
Bind {
20382038
portal: "",

src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ pub enum IsNull {
605605
}
606606

607607
/// A trait for types that can be converted into Postgres values.
608-
pub trait ToSql {
608+
pub trait ToSql: fmt::Debug {
609609
/// Converts the value of `self` into the binary format of the specified
610610
/// Postgres `Type`, writing it to `out`.
611611
///

src/types/slice.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use types::IsNull;
2424
/// }
2525
/// # Ok(()) }
2626
/// ```
27+
#[derive(Debug)]
2728
pub struct Slice<'a, T: 'a + ToSql>(pub &'a [T]);
2829

2930
impl<'a, T: 'a + ToSql> ToSql for Slice<'a, T> {

0 commit comments

Comments
 (0)