Remove deprecated from_sql_nullable

This commit is contained in:
Steven Fackler 2015-11-14 17:05:31 -08:00
parent 736f530ae9
commit afc067fb33
3 changed files with 28 additions and 37 deletions

View File

@ -725,29 +725,30 @@ impl InnerConnection {
}
_ => bad_response!(self),
}
let (name, elem_oid, rngsubtype, schema): (String, Oid, Option<Oid>, 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::<Oid>::from_sql(&Type::Oid, &mut &**data, &ctx)),
None => try!(Option::<Oid>::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 } => {

View File

@ -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.

View File

@ -596,17 +596,6 @@ impl error::Error for WasNull {
/// `Option<T>` where `T` implements `FromSql`. An `Option<T>` represents a
/// nullable Postgres value.
pub trait FromSql: Sized {
/// ### Deprecated
fn from_sql_nullable<R: Read>(ty: &Type,
raw: Option<&mut R>,
ctx: &SessionInfo)
-> Result<Self> {
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`.
///