Update for API changes
Lots of stuff this time!
This commit is contained in:
parent
832316967b
commit
2c55ae5669
@ -1 +1 @@
|
|||||||
Subproject commit 3491ce3add5a93db2decf61d160daf3424f6cf3d
|
Subproject commit d752241bf21e60575bf89f24c4359b34aef20d9c
|
22
tests.rs
22
tests.rs
@ -41,18 +41,18 @@ fn test_pool() {
|
|||||||
let (stream1, stream2) = DuplexStream::<(), ()>::new();
|
let (stream1, stream2) = DuplexStream::<(), ()>::new();
|
||||||
|
|
||||||
let pool1 = pool.clone();
|
let pool1 = pool.clone();
|
||||||
let mut fut1 = do Future::spawn {
|
let mut fut1 = Future::spawn(proc() {
|
||||||
let _conn = pool1.get_connection();
|
let _conn = pool1.get_connection();
|
||||||
stream1.send(());
|
stream1.send(());
|
||||||
stream1.recv();
|
stream1.recv();
|
||||||
};
|
});
|
||||||
|
|
||||||
let pool2 = pool.clone();
|
let pool2 = pool.clone();
|
||||||
let mut fut2 = do Future::spawn {
|
let mut fut2 = Future::spawn(proc() {
|
||||||
let _conn = pool2.get_connection();
|
let _conn = pool2.get_connection();
|
||||||
stream2.send(());
|
stream2.send(());
|
||||||
stream2.recv();
|
stream2.recv();
|
||||||
};
|
});
|
||||||
|
|
||||||
fut1.get();
|
fut1.get();
|
||||||
fut2.get();
|
fut2.get();
|
||||||
@ -581,23 +581,23 @@ fn test_f64_nan_param() {
|
|||||||
#[should_fail]
|
#[should_fail]
|
||||||
fn test_wrong_param_type() {
|
fn test_wrong_param_type() {
|
||||||
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
|
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
|
||||||
conn.try_execute("SELECT $1::VARCHAR", [&1i32 as &ToSql]);
|
let _ = conn.try_execute("SELECT $1::VARCHAR", [&1i32 as &ToSql]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_fail]
|
#[should_fail]
|
||||||
fn test_too_few_params() {
|
fn test_too_few_params() {
|
||||||
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
|
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
|
||||||
conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql]);
|
let _ = conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_fail]
|
#[should_fail]
|
||||||
fn test_too_many_params() {
|
fn test_too_many_params() {
|
||||||
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
|
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
|
||||||
conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql,
|
let _ = conn.try_execute("SELECT $1::INT, $2::INT", [&1i32 as &ToSql,
|
||||||
&2i32 as &ToSql,
|
&2i32 as &ToSql,
|
||||||
&3i32 as &ToSql]);
|
&3i32 as &ToSql]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -695,11 +695,11 @@ fn test_cancel_query() {
|
|||||||
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
|
let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl);
|
||||||
let cancel_data = conn.cancel_data();
|
let cancel_data = conn.cancel_data();
|
||||||
|
|
||||||
do spawn {
|
spawn(proc() {
|
||||||
timer::sleep(500);
|
timer::sleep(500);
|
||||||
assert!(super::cancel_query("postgres://postgres@localhost", &NoSsl,
|
assert!(super::cancel_query("postgres://postgres@localhost", &NoSsl,
|
||||||
cancel_data).is_ok());
|
cancel_data).is_ok());
|
||||||
}
|
});
|
||||||
|
|
||||||
match conn.try_execute("SELECT pg_sleep(10)", []) {
|
match conn.try_execute("SELECT pg_sleep(10)", []) {
|
||||||
Err(PostgresDbError { code: QueryCanceled, .. }) => {}
|
Err(PostgresDbError { code: QueryCanceled, .. }) => {}
|
||||||
|
16
types/mod.rs
16
types/mod.rs
@ -545,15 +545,15 @@ macro_rules! to_range_impl(
|
|||||||
if self.is_empty() {
|
if self.is_empty() {
|
||||||
tag |= RANGE_EMPTY;
|
tag |= RANGE_EMPTY;
|
||||||
} else {
|
} else {
|
||||||
match *self.lower() {
|
match self.lower() {
|
||||||
None => tag |= RANGE_LOWER_UNBOUNDED,
|
None => tag |= RANGE_LOWER_UNBOUNDED,
|
||||||
Some(RangeBound { type_: Inclusive, .. }) =>
|
Some(&RangeBound { type_: Inclusive, .. }) =>
|
||||||
tag |= RANGE_LOWER_INCLUSIVE,
|
tag |= RANGE_LOWER_INCLUSIVE,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
match *self.upper() {
|
match self.upper() {
|
||||||
None => tag |= RANGE_UPPER_UNBOUNDED,
|
None => tag |= RANGE_UPPER_UNBOUNDED,
|
||||||
Some(RangeBound { type_: Inclusive, .. }) =>
|
Some(&RangeBound { type_: Inclusive, .. }) =>
|
||||||
tag |= RANGE_UPPER_INCLUSIVE,
|
tag |= RANGE_UPPER_INCLUSIVE,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@ -561,8 +561,8 @@ macro_rules! to_range_impl(
|
|||||||
|
|
||||||
buf.write_i8(tag);
|
buf.write_i8(tag);
|
||||||
|
|
||||||
match *self.lower() {
|
match self.lower() {
|
||||||
Some(ref bound) => {
|
Some(bound) => {
|
||||||
let mut inner_buf = MemWriter::new();
|
let mut inner_buf = MemWriter::new();
|
||||||
bound.value.raw_to_sql(&mut inner_buf);
|
bound.value.raw_to_sql(&mut inner_buf);
|
||||||
let inner_buf = inner_buf.unwrap();
|
let inner_buf = inner_buf.unwrap();
|
||||||
@ -571,8 +571,8 @@ macro_rules! to_range_impl(
|
|||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
match *self.upper() {
|
match self.upper() {
|
||||||
Some(ref bound) => {
|
Some(bound) => {
|
||||||
let mut inner_buf = MemWriter::new();
|
let mut inner_buf = MemWriter::new();
|
||||||
bound.value.raw_to_sql(&mut inner_buf);
|
bound.value.raw_to_sql(&mut inner_buf);
|
||||||
let inner_buf = inner_buf.unwrap();
|
let inner_buf = inner_buf.unwrap();
|
||||||
|
@ -207,15 +207,15 @@ impl<S: BoundSided, T: Ord> RangeBound<S, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct OptBound<'a, S, T>(&'a Option<RangeBound<S, T>>);
|
struct OptBound<'a, S, T>(Option<&'a RangeBound<S, T>>);
|
||||||
|
|
||||||
impl<'a, S: BoundSided, T: Ord> Ord for OptBound<'a, S, T> {
|
impl<'a, S: BoundSided, T: Ord> Ord for OptBound<'a, S, T> {
|
||||||
fn lt(&self, other: &OptBound<'a, S, T>) -> bool {
|
fn lt(&self, other: &OptBound<'a, S, T>) -> bool {
|
||||||
match (*self, *other) {
|
match (*self, *other) {
|
||||||
(OptBound(&None), OptBound(&None)) => false,
|
(OptBound(None), OptBound(None)) => false,
|
||||||
(OptBound(&None), _) => BoundSided::side(None::<S>) == Lower,
|
(OptBound(None), _) => BoundSided::side(None::<S>) == Lower,
|
||||||
(_, OptBound(&None)) => BoundSided::side(None::<S>) == Upper,
|
(_, OptBound(None)) => BoundSided::side(None::<S>) == Upper,
|
||||||
(OptBound(&Some(ref a)), OptBound(&Some(ref b))) => a < b
|
(OptBound(Some(a)), OptBound(Some(b))) => a < b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,18 +267,18 @@ impl<T: Ord+Normalizable> Range<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the lower bound if it exists.
|
/// Returns the lower bound if it exists.
|
||||||
pub fn lower<'a>(&'a self) -> &'a Option<RangeBound<LowerBound, T>> {
|
pub fn lower<'a>(&'a self) -> Option<&'a RangeBound<LowerBound, T>> {
|
||||||
match *self {
|
match *self {
|
||||||
Empty => &None,
|
Normal(Some(ref lower), _) => Some(lower),
|
||||||
Normal(ref lower, _) => lower
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the upper bound if it exists.
|
/// Returns the upper bound if it exists.
|
||||||
pub fn upper<'a>(&'a self) -> &'a Option<RangeBound<UpperBound, T>> {
|
pub fn upper<'a>(&'a self) -> Option<&'a RangeBound<UpperBound, T>> {
|
||||||
match *self {
|
match *self {
|
||||||
Empty => &None,
|
Normal(_, Some(ref upper)) => Some(upper),
|
||||||
Normal(_, ref upper) => upper
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ impl<T: Ord+Normalizable+Clone> Range<T> {
|
|||||||
let OptBound(upper) = cmp::min(OptBound(self.upper()),
|
let OptBound(upper) = cmp::min(OptBound(self.upper()),
|
||||||
OptBound(other.upper()));
|
OptBound(other.upper()));
|
||||||
|
|
||||||
Range::new(lower.clone(), upper.clone())
|
Range::new(lower.map(|v| v.clone()), upper.map(|v| v.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +467,8 @@ mod test {
|
|||||||
assert_eq!(r1, (range!('(', ')')).intersect(&r1));
|
assert_eq!(r1, (range!('(', ')')).intersect(&r1));
|
||||||
|
|
||||||
let r2 = range!('(' 10i32, ')');
|
let r2 = range!('(' 10i32, ')');
|
||||||
let exp = Range::new(r2.lower().clone(), r1.upper().clone());
|
let exp = Range::new(r2.lower().map(|v| v.clone()),
|
||||||
|
r1.upper().map(|v| v.clone()));
|
||||||
assert_eq!(exp, r1.intersect(&r2));
|
assert_eq!(exp, r1.intersect(&r2));
|
||||||
assert_eq!(exp, r2.intersect(&r1));
|
assert_eq!(exp, r2.intersect(&r1));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user