Skip to content

Commit afc067f

Browse files
committed
Remove deprecated from_sql_nullable
1 parent 736f530 commit afc067f

3 files changed

Lines changed: 28 additions & 37 deletions

File tree

src/lib.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -725,29 +725,30 @@ impl InnerConnection {
725725
}
726726
_ => bad_response!(self),
727727
}
728-
let (name, elem_oid, rngsubtype, schema): (String, Oid, Option<Oid>, String) =
729-
match try!(self.read_message()) {
730-
DataRow { row } => {
731-
let ctx = SessionInfo::new(self);
732-
(try!(FromSql::from_sql_nullable(&Type::Name,
733-
row[0].as_ref().map(|r| &**r).as_mut(),
734-
&ctx)),
735-
try!(FromSql::from_sql_nullable(&Type::Oid,
736-
row[1].as_ref().map(|r| &**r).as_mut(),
737-
&ctx)),
738-
try!(FromSql::from_sql_nullable(&Type::Oid,
739-
row[2].as_ref().map(|r| &**r).as_mut(),
740-
&ctx)),
741-
try!(FromSql::from_sql_nullable(&Type::Name,
742-
row[3].as_ref().map(|r| &**r).as_mut(),
743-
&ctx)))
744-
}
745-
ErrorResponse { fields } => {
746-
try!(self.wait_for_ready());
747-
return DbError::new(fields);
748-
}
749-
_ => bad_response!(self),
750-
};
728+
let (name, elem_oid, rngsubtype, schema) = match try!(self.read_message()) {
729+
DataRow { row } => {
730+
let ctx = SessionInfo::new(self);
731+
let name = try!(String::from_sql(&Type::Name,
732+
&mut &**row[0].as_ref().unwrap(),
733+
&ctx));
734+
let elem_oid = try!(Oid::from_sql(&Type::Oid,
735+
&mut &**row[1].as_ref().unwrap(),
736+
&ctx));
737+
let rngsubtype = match row[2] {
738+
Some(ref data) => try!(Option::<Oid>::from_sql(&Type::Oid, &mut &**data, &ctx)),
739+
None => try!(Option::<Oid>::from_sql_null(&Type::Oid, &ctx)),
740+
};
741+
let schema = try!(String::from_sql(&Type::Name,
742+
&mut &**row[3].as_ref().unwrap(),
743+
&ctx));
744+
(name, elem_oid, rngsubtype, schema)
745+
}
746+
ErrorResponse { fields } => {
747+
try!(self.wait_for_ready());
748+
return DbError::new(fields);
749+
}
750+
_ => bad_response!(self)
751+
};
751752
match try!(self.read_message()) {
752753
CommandComplete { .. } => {}
753754
ErrorResponse { fields } => {

src/rows.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,10 @@ impl<'a> Row<'a> {
180180
return Err(Error::WrongType(ty.clone()));
181181
}
182182
let conn = self.stmt.conn().conn.borrow();
183-
FromSql::from_sql_nullable(ty,
184-
self.data[idx].as_ref().map(|e| &**e).as_mut(),
185-
&SessionInfo::new(&*conn))
183+
match self.data[idx] {
184+
Some(ref data) => FromSql::from_sql(ty, &mut &**data, &SessionInfo::new(&*conn)),
185+
None => FromSql::from_sql_null(ty, &SessionInfo::new(&*conn))
186+
}
186187
}
187188

188189
/// Retrieves the contents of a field of the row.

src/types/mod.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -596,17 +596,6 @@ impl error::Error for WasNull {
596596
/// `Option<T>` where `T` implements `FromSql`. An `Option<T>` represents a
597597
/// nullable Postgres value.
598598
pub trait FromSql: Sized {
599-
/// ### Deprecated
600-
fn from_sql_nullable<R: Read>(ty: &Type,
601-
raw: Option<&mut R>,
602-
ctx: &SessionInfo)
603-
-> Result<Self> {
604-
match raw {
605-
Some(raw) => FromSql::from_sql(ty, raw, ctx),
606-
None => FromSql::from_sql_null(ty, ctx),
607-
}
608-
}
609-
610599
/// Creates a new value of this type from a `Read`er of the binary format
611600
/// of the specified Postgres `Type`.
612601
///

0 commit comments

Comments
 (0)