Skip to content

Commit c536e49

Browse files
committed
Update to the latest postgres
1 parent 402c3c0 commit c536e49

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

Cargo.toml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
[package]
22
name = "postgres_range"
3-
version = "0.8.2"
3+
version = "0.9.0"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
55
license = "MIT"
66
description = "Range support for rust-postgres"
77
repository = "https://github.com/sfackler/rust-postgres-range"
8-
documentation = "https://sfackler.github.io/rust-postgres-range/doc/v0.8.2/postgres_range"
8+
documentation = "https://sfackler.github.io/rust-postgres-range/doc/v0.9.0/postgres_range"
99

1010
[dependencies]
1111
time = "0.1"
12-
postgres = "0.11"
13-
postgres-protocol = { git = "https://github.com/sfackler/rust-postgres-protocol" }
12+
postgres = "0.15"
13+
postgres-protocol = "0.3"
1414

1515
[dev-dependencies]
16-
postgres = { version = "0.11", features = ["with-time"] }
17-
18-
[replace]
19-
"postgres:0.11.11" = { git = "https://github.com/sfackler/rust-postgres" }
20-
"fallible-iterator:0.1.2" = { git = "https://github.com/sfackler/rust-fallible-iterator" }
16+
postgres = { version = "0.15", features = ["with-time"] }

src/impls.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::error::Error;
2-
use postgres::types::{Type, Kind, ToSql, FromSql, IsNull, SessionInfo};
3-
use postgres_protocol::types;
2+
use postgres::types::{Type, Kind, ToSql, FromSql, IsNull};
3+
use postgres_protocol::{self as protocol, types};
44

55
use {Range, RangeBound, BoundType, BoundSided, Normalizable};
66

77
impl<T> FromSql for Range<T> where T: PartialOrd+Normalizable+FromSql {
8-
fn from_sql(ty: &Type, raw: &[u8], info: &SessionInfo) -> Result<Range<T>, Box<Error + Sync + Send>> {
8+
fn from_sql(ty: &Type, raw: &[u8]) -> Result<Range<T>, Box<Error + Sync + Send>> {
99
let element_type = match ty.kind() {
1010
&Kind::Range(ref ty) => ty,
1111
_ => panic!("unexpected type {:?}", ty)
@@ -14,8 +14,8 @@ impl<T> FromSql for Range<T> where T: PartialOrd+Normalizable+FromSql {
1414
match try!(types::range_from_sql(raw)) {
1515
types::Range::Empty => Ok(Range::empty()),
1616
types::Range::Nonempty(lower, upper) => {
17-
let lower = try!(bound_from_sql(lower, element_type, info));
18-
let upper = try!(bound_from_sql(upper, element_type, info));
17+
let lower = try!(bound_from_sql(lower, element_type));
18+
let upper = try!(bound_from_sql(upper, element_type));
1919
Ok(Range::new(lower, upper))
2020
}
2121
}
@@ -29,22 +29,22 @@ impl<T> FromSql for Range<T> where T: PartialOrd+Normalizable+FromSql {
2929
}
3030
}
3131

32-
fn bound_from_sql<T, S>(bound: types::RangeBound<Option<&[u8]>>, ty: &Type, info: &SessionInfo) -> Result<Option<RangeBound<S, T>>, Box<Error + Sync + Send>>
32+
fn bound_from_sql<T, S>(bound: types::RangeBound<Option<&[u8]>>, ty: &Type) -> Result<Option<RangeBound<S, T>>, Box<Error + Sync + Send>>
3333
where T: PartialOrd + Normalizable + FromSql,
3434
S: BoundSided
3535
{
3636
match bound {
3737
types::RangeBound::Exclusive(value) => {
3838
let value = match value {
39-
Some(value) => try!(T::from_sql(ty, value, info)),
40-
None => try!(T::from_sql_null(ty, info)),
39+
Some(value) => try!(T::from_sql(ty, value)),
40+
None => try!(T::from_sql_null(ty)),
4141
};
4242
Ok(Some(RangeBound::new(value, BoundType::Exclusive)))
4343
},
4444
types::RangeBound::Inclusive(value) => {
4545
let value = match value {
46-
Some(value) => try!(T::from_sql(ty, value, info)),
47-
None => try!(T::from_sql_null(ty, info)),
46+
Some(value) => try!(T::from_sql(ty, value)),
47+
None => try!(T::from_sql_null(ty)),
4848
};
4949
Ok(Some(RangeBound::new(value, BoundType::Inclusive)))
5050
},
@@ -53,7 +53,7 @@ fn bound_from_sql<T, S>(bound: types::RangeBound<Option<&[u8]>>, ty: &Type, info
5353
}
5454

5555
impl<T> ToSql for Range<T> where T: PartialOrd+Normalizable+ToSql {
56-
fn to_sql(&self, ty: &Type, mut buf: &mut Vec<u8>, info: &SessionInfo) -> Result<IsNull, Box<Error + Sync + Send>> {
56+
fn to_sql(&self, ty: &Type, buf: &mut Vec<u8>) -> Result<IsNull, Box<Error + Sync + Send>> {
5757
let element_type = match ty.kind() {
5858
&Kind::Range(ref ty) => ty,
5959
_ => panic!("unexpected type {:?}", ty)
@@ -62,8 +62,8 @@ impl<T> ToSql for Range<T> where T: PartialOrd+Normalizable+ToSql {
6262
if self.is_empty() {
6363
types::empty_range_to_sql(buf);
6464
} else {
65-
try!(types::range_to_sql(|buf| bound_to_sql(self.lower(), element_type, info, buf),
66-
|buf| bound_to_sql(self.upper(), element_type, info, buf),
65+
try!(types::range_to_sql(|buf| bound_to_sql(self.lower(), element_type, buf),
66+
|buf| bound_to_sql(self.upper(), element_type, buf),
6767
buf));
6868
}
6969

@@ -80,15 +80,15 @@ impl<T> ToSql for Range<T> where T: PartialOrd+Normalizable+ToSql {
8080
to_sql_checked!();
8181
}
8282

83-
fn bound_to_sql<S, T>(bound: Option<&RangeBound<S, T>>, ty: &Type, info: &SessionInfo, buf: &mut Vec<u8>) -> Result<types::RangeBound<types::IsNull>, Box<Error + Sync + Send>>
83+
fn bound_to_sql<S, T>(bound: Option<&RangeBound<S, T>>, ty: &Type, buf: &mut Vec<u8>) -> Result<types::RangeBound<protocol::IsNull>, Box<Error + Sync + Send>>
8484
where S: BoundSided,
8585
T: ToSql
8686
{
8787
match bound {
8888
Some(bound) => {
89-
let null = match try!(bound.value.to_sql(ty, buf, info)) {
90-
IsNull::Yes => types::IsNull::Yes,
91-
IsNull::No => types::IsNull::No,
89+
let null = match try!(bound.value.to_sql(ty, buf)) {
90+
IsNull::Yes => protocol::IsNull::Yes,
91+
IsNull::No => protocol::IsNull::No,
9292
};
9393

9494
match bound.type_ {

0 commit comments

Comments
 (0)