From afc067fb3393714ab4baa2d8cd2b9c66c2fceef0 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 14 Nov 2015 17:05:31 -0800 Subject: [PATCH] Remove deprecated from_sql_nullable --- src/lib.rs | 47 ++++++++++++++++++++++++----------------------- src/rows.rs | 7 ++++--- src/types/mod.rs | 11 ----------- 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4aae76a9..fdeb0557 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -725,29 +725,30 @@ impl InnerConnection { } _ => bad_response!(self), } - let (name, elem_oid, rngsubtype, schema): (String, Oid, Option, String) = - match try!(self.read_message()) { - DataRow { row } => { - let ctx = SessionInfo::new(self); - (try!(FromSql::from_sql_nullable(&Type::Name, - row[0].as_ref().map(|r| &**r).as_mut(), - &ctx)), - try!(FromSql::from_sql_nullable(&Type::Oid, - row[1].as_ref().map(|r| &**r).as_mut(), - &ctx)), - try!(FromSql::from_sql_nullable(&Type::Oid, - row[2].as_ref().map(|r| &**r).as_mut(), - &ctx)), - try!(FromSql::from_sql_nullable(&Type::Name, - row[3].as_ref().map(|r| &**r).as_mut(), - &ctx))) - } - ErrorResponse { fields } => { - try!(self.wait_for_ready()); - return DbError::new(fields); - } - _ => bad_response!(self), - }; + let (name, elem_oid, rngsubtype, schema) = match try!(self.read_message()) { + DataRow { row } => { + let ctx = SessionInfo::new(self); + let name = try!(String::from_sql(&Type::Name, + &mut &**row[0].as_ref().unwrap(), + &ctx)); + let elem_oid = try!(Oid::from_sql(&Type::Oid, + &mut &**row[1].as_ref().unwrap(), + &ctx)); + let rngsubtype = match row[2] { + Some(ref data) => try!(Option::::from_sql(&Type::Oid, &mut &**data, &ctx)), + None => try!(Option::::from_sql_null(&Type::Oid, &ctx)), + }; + let schema = try!(String::from_sql(&Type::Name, + &mut &**row[3].as_ref().unwrap(), + &ctx)); + (name, elem_oid, rngsubtype, schema) + } + ErrorResponse { fields } => { + try!(self.wait_for_ready()); + return DbError::new(fields); + } + _ => bad_response!(self) + }; match try!(self.read_message()) { CommandComplete { .. } => {} ErrorResponse { fields } => { diff --git a/src/rows.rs b/src/rows.rs index 03ab9dac..2083dc17 100644 --- a/src/rows.rs +++ b/src/rows.rs @@ -180,9 +180,10 @@ impl<'a> Row<'a> { return Err(Error::WrongType(ty.clone())); } let conn = self.stmt.conn().conn.borrow(); - FromSql::from_sql_nullable(ty, - self.data[idx].as_ref().map(|e| &**e).as_mut(), - &SessionInfo::new(&*conn)) + match self.data[idx] { + Some(ref data) => FromSql::from_sql(ty, &mut &**data, &SessionInfo::new(&*conn)), + None => FromSql::from_sql_null(ty, &SessionInfo::new(&*conn)) + } } /// Retrieves the contents of a field of the row. diff --git a/src/types/mod.rs b/src/types/mod.rs index 6971fd9f..fe2ee64f 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -596,17 +596,6 @@ impl error::Error for WasNull { /// `Option` where `T` implements `FromSql`. An `Option` represents a /// nullable Postgres value. pub trait FromSql: Sized { - /// ### Deprecated - fn from_sql_nullable(ty: &Type, - raw: Option<&mut R>, - ctx: &SessionInfo) - -> Result { - match raw { - Some(raw) => FromSql::from_sql(ty, raw, ctx), - None => FromSql::from_sql_null(ty, ctx), - } - } - /// Creates a new value of this type from a `Read`er of the binary format /// of the specified Postgres `Type`. ///