Skip to content

Commit e6b45ed

Browse files
committed
Update for upstream changes
1 parent adc81a9 commit e6b45ed

5 files changed

Lines changed: 52 additions & 48 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn main() {
3939
)", []).unwrap();
4040
let me = Person {
4141
id: 0,
42-
name: "Steven".to_owned(),
42+
name: "Steven".to_string(),
4343
time_created: time::get_time(),
4444
data: None
4545
};

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ macro_rules! make_errors(
2929
pub fn from_code(s: &str) -> PostgresSqlState {
3030
match STATE_MAP.find(&s) {
3131
Some(state) => state.clone(),
32-
None => UnknownSqlState(s.to_owned())
32+
None => UnknownSqlState(s.to_string())
3333
}
3434
}
3535
}

src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn main() {
3131
)", []).unwrap();
3232
let me = Person {
3333
id: 0,
34-
name: "Steven".to_owned(),
34+
name: "Steven".to_string(),
3535
time_created: time::get_time(),
3636
data: None
3737
};
@@ -283,15 +283,15 @@ impl IntoConnectParams for Url {
283283
let port = match port {
284284
Some(port) => match FromStr::from_str(port.as_slice()) {
285285
Some(port) => Some(port),
286-
None => return Err(InvalidUrl("invalid port".to_owned())),
286+
None => return Err(InvalidUrl("invalid port".to_string())),
287287
},
288288
None => None,
289289
};
290290

291291
let database = if !path.is_empty() {
292292
// path contains the leading /
293293
let (_, path) = path.as_slice().slice_shift_char();
294-
Some(path.to_owned())
294+
Some(path.to_string())
295295
} else {
296296
None
297297
};
@@ -325,6 +325,7 @@ impl PostgresNoticeHandler for DefaultNoticeHandler {
325325
}
326326

327327
/// An asynchronous notification
328+
#[deriving(Show)]
328329
pub struct PostgresNotification {
329330
/// The process ID of the notifying backend process
330331
pub pid: i32,
@@ -459,14 +460,14 @@ impl InnerPostgresConnection {
459460
canary: CANARY,
460461
};
461462

462-
options.push(("client_encoding".to_owned(), "UTF8".to_owned()));
463+
options.push(("client_encoding".to_string(), "UTF8".to_string()));
463464
// Postgres uses the value of TimeZone as the time zone for TIMESTAMP
464465
// WITH TIME ZONE values. Timespec converts to GMT internally.
465-
options.push(("TimeZone".to_owned(), "GMT".to_owned()));
466+
options.push(("TimeZone".to_string(), "GMT".to_string()));
466467
// We have to clone here since we need the user again for auth
467-
options.push(("user".to_owned(), user.clone()));
468+
options.push(("user".to_string(), user.clone()));
468469
match database {
469-
Some(database) => options.push(("database".to_owned(), database)),
470+
Some(database) => options.push(("database".to_string(), database)),
470471
None => {}
471472
}
472473

@@ -755,7 +756,7 @@ impl PostgresConnection {
755756
/// let params = PostgresConnectParams {
756757
/// target: TargetUnix(some_crazy_path),
757758
/// port: None,
758-
/// user: Some("postgres".to_owned()),
759+
/// user: Some("postgres".to_string()),
759760
/// password: None,
760761
/// database: None,
761762
/// options: vec![],

src/test.rs

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,17 @@ fn test_prepare_err() {
9090
let conn = or_fail!(PostgresConnection::connect("postgres://postgres@localhost", &NoSsl));
9191
match conn.prepare("invalid sql statment") {
9292
Err(PgDbError(PostgresDbError { code: SyntaxError, position: Some(Position(1)), .. })) => (),
93-
resp => fail!("Unexpected result {:?}", resp)
93+
Err(e) => fail!("Unexpected result {}", e),
94+
_ => fail!("Unexpected result"),
9495
}
9596
}
9697

9798
#[test]
9899
fn test_unknown_database() {
99100
match PostgresConnection::connect("postgres://postgres@localhost/asdf", &NoSsl) {
100101
Err(PgConnectDbError(PostgresDbError { code: InvalidCatalogName, .. })) => {}
101-
resp => fail!("Unexpected result {:?}", resp)
102+
Err(resp) => fail!("Unexpected result {}", resp),
103+
_ => fail!("Unexpected result"),
102104
}
103105
}
104106

@@ -402,8 +404,8 @@ fn test_result_descriptions() {
402404
let conn = or_fail!(PostgresConnection::connect("postgres://postgres@localhost", &NoSsl));
403405
let stmt = or_fail!(conn.prepare("SELECT 1::INT as a, 'hi'::VARCHAR as b"));
404406
assert!(stmt.result_descriptions() ==
405-
[ResultDescription { name: "a".to_owned(), ty: PgInt4},
406-
ResultDescription { name: "b".to_owned(), ty: PgVarchar}]);
407+
[ResultDescription { name: "a".to_string(), ty: PgInt4},
408+
ResultDescription { name: "b".to_string(), ty: PgVarchar}]);
407409
}
408410

409411
#[test]
@@ -445,8 +447,8 @@ fn test_i8_params() {
445447

446448
#[test]
447449
fn test_name_params() {
448-
test_type("NAME", [(Some("hello world".to_owned()), "'hello world'"),
449-
(Some("イロハニホヘト チリヌルヲ".to_owned()), "'イロハニホヘト チリヌルヲ'"),
450+
test_type("NAME", [(Some("hello world".to_string()), "'hello world'"),
451+
(Some("イロハニホヘト チリヌルヲ".to_string()), "'イロハニホヘト チリヌルヲ'"),
450452
(None, "NULL")]);
451453
}
452454

@@ -486,15 +488,15 @@ fn test_f64_params() {
486488

487489
#[test]
488490
fn test_varchar_params() {
489-
test_type("VARCHAR", [(Some("hello world".to_owned()), "'hello world'"),
490-
(Some("イロハニホヘト チリヌルヲ".to_owned()), "'イロハニホヘト チリヌルヲ'"),
491+
test_type("VARCHAR", [(Some("hello world".to_string()), "'hello world'"),
492+
(Some("イロハニホヘト チリヌルヲ".to_string()), "'イロハニホヘト チリヌルヲ'"),
491493
(None, "NULL")]);
492494
}
493495

494496
#[test]
495497
fn test_text_params() {
496-
test_type("TEXT", [(Some("hello world".to_owned()), "'hello world'"),
497-
(Some("イロハニホヘト チリヌルヲ".to_owned()), "'イロハニホヘト チリヌルヲ'"),
498+
test_type("TEXT", [(Some("hello world".to_string()), "'hello world'"),
499+
(Some("イロハニホヘト チリヌルヲ".to_string()), "'イロハニホヘト チリヌルヲ'"),
498500
(None, "NULL")]);
499501
}
500502

@@ -511,7 +513,7 @@ fn test_bpchar_params() {
511513
let stmt = or_fail!(conn.prepare("SELECT b FROM foo ORDER BY id"));
512514
let res = or_fail!(stmt.query([]));
513515

514-
assert_eq!(vec!(Some("12345".to_owned()), Some("123 ".to_owned()), None),
516+
assert_eq!(vec!(Some("12345".to_string()), Some("123 ".to_string()), None),
515517
res.map(|row| row[1]).collect());
516518
}
517519

@@ -556,7 +558,7 @@ fn test_tm_params() {
556558

557559
macro_rules! test_range(
558560
($name:expr, $t:ty, $low:expr, $low_str:expr, $high:expr, $high_str:expr) => ({
559-
let tests = [(Some(range!('(', ')')), "'(,)'".to_owned()),
561+
let tests = [(Some(range!('(', ')')), "'(,)'".to_string()),
560562
(Some(range!('[' $low, ')')), format!("'[{},)'", $low_str)),
561563
(Some(range!('(' $low, ')')), format!("'({},)'", $low_str)),
562564
(Some(range!('(', $high ']')), format!("'(,{}]'", $high_str)),
@@ -569,8 +571,8 @@ macro_rules! test_range(
569571
format!("'({},{}]'", $low_str, $high_str)),
570572
(Some(range!('(' $low, $high ')')),
571573
format!("'({},{})'", $low_str, $high_str)),
572-
(Some(range!(empty)), "'empty'".to_owned()),
573-
(None, "NULL".to_owned())];
574+
(Some(range!(empty)), "'empty'".to_string()),
575+
(None, "NULL".to_string())];
574576
test_type($name, tests);
575577
})
576578
)
@@ -607,14 +609,14 @@ fn test_tstzrange_params() {
607609
macro_rules! test_array_params(
608610
($name:expr, $v1:expr, $s1:expr, $v2:expr, $s2:expr, $v3:expr, $s3:expr) => ({
609611
let tests = [(Some(ArrayBase::from_vec(vec!(Some($v1), Some($v2), None), 1)),
610-
format!(r"'\{{},{},NULL\}'", $s1, $s2).into_owned()),
611-
(None, "NULL".to_owned())];
612+
format!(r"'\{{},{},NULL\}'", $s1, $s2).into_string()),
613+
(None, "NULL".to_string())];
612614
test_type(format!("{}[]", $name).as_slice(), tests);
613615
let mut a = ArrayBase::from_vec(vec!(Some($v1), Some($v2)), 0);
614616
a.wrap(-1);
615617
a.push_move(ArrayBase::from_vec(vec!(None, Some($v3)), 0));
616618
let tests = [(Some(a), format!(r"'[-1:0][0:1]=\{\{{},{}\},\{NULL,{}\}\}'",
617-
$s1, $s2, $s3).into_owned())];
619+
$s1, $s2, $s3).into_string())];
618620
test_type(format!("{}[][]", $name).as_slice(), tests);
619621
})
620622
)
@@ -638,8 +640,8 @@ fn test_chararray_params() {
638640

639641
#[test]
640642
fn test_namearray_params() {
641-
test_array_params!("NAME", "hello".to_owned(), "hello", "world".to_owned(),
642-
"world", "!".to_owned(), "!");
643+
test_array_params!("NAME", "hello".to_string(), "hello", "world".to_string(),
644+
"world", "!".to_string(), "!");
643645
}
644646

645647
#[test]
@@ -654,20 +656,20 @@ fn test_int4array_params() {
654656

655657
#[test]
656658
fn test_textarray_params() {
657-
test_array_params!("TEXT", "hello".to_owned(), "hello", "world".to_owned(),
658-
"world", "!".to_owned(), "!");
659+
test_array_params!("TEXT", "hello".to_string(), "hello", "world".to_string(),
660+
"world", "!".to_string(), "!");
659661
}
660662

661663
#[test]
662664
fn test_charnarray_params() {
663-
test_array_params!("CHAR(5)", "hello".to_owned(), "hello",
664-
"world".to_owned(), "world", "! ".to_owned(), "!");
665+
test_array_params!("CHAR(5)", "hello".to_string(), "hello",
666+
"world".to_string(), "world", "! ".to_string(), "!");
665667
}
666668

667669
#[test]
668670
fn test_varchararray_params() {
669-
test_array_params!("VARCHAR", "hello".to_owned(), "hello",
670-
"world".to_owned(), "world", "!".to_owned(), "!");
671+
test_array_params!("VARCHAR", "hello".to_string(), "hello",
672+
"world".to_string(), "world", "!".to_string(), "!");
671673
}
672674

673675
#[test]
@@ -751,10 +753,10 @@ fn test_hstore_params() {
751753
})
752754
)
753755
test_type("hstore",
754-
[(Some(make_map!("a".to_owned() => Some("1".to_owned()))), "'a=>1'"),
755-
(Some(make_map!("hello".to_owned() => Some("world!".to_owned()),
756-
"hola".to_owned() => Some("mundo!".to_owned()),
757-
"what".to_owned() => None)),
756+
[(Some(make_map!("a".to_string() => Some("1".to_string()))), "'a=>1'"),
757+
(Some(make_map!("hello".to_string() => Some("world!".to_string()),
758+
"hola".to_string() => Some("mundo!".to_string()),
759+
"what".to_string() => None)),
758760
"'hello=>world!,hola=>mundo!,what=>NULL'"),
759761
(None, "NULL")]);
760762
}
@@ -894,7 +896,7 @@ fn test_notification_iterator_some() {
894896
assert_eq!(&expected.channel, &channel);
895897
assert_eq!(&expected.payload, &payload);
896898
}
897-
x => fail!("Expected {:?} but got {:?}", expected, x)
899+
x => fail!("Expected {} but got {}", expected, x)
898900
}
899901
}
900902

@@ -907,21 +909,21 @@ fn test_notification_iterator_some() {
907909

908910
check_notification(PostgresNotification {
909911
pid: 0,
910-
channel: "test_notification_iterator_one_channel".to_owned(),
911-
payload: "hello".to_owned()
912+
channel: "test_notification_iterator_one_channel".to_string(),
913+
payload: "hello".to_string()
912914
}, it.next());
913915
check_notification(PostgresNotification {
914916
pid: 0,
915-
channel: "test_notification_iterator_one_channel2".to_owned(),
916-
payload: "world".to_owned()
917+
channel: "test_notification_iterator_one_channel2".to_string(),
918+
payload: "world".to_string()
917919
}, it.next());
918920
assert!(it.next().is_none());
919921

920922
or_fail!(conn.execute("NOTIFY test_notification_iterator_one_channel, '!'", []));
921923
check_notification(PostgresNotification {
922924
pid: 0,
923-
channel: "test_notification_iterator_one_channel".to_owned(),
924-
payload: "!".to_owned()
925+
channel: "test_notification_iterator_one_channel".to_string(),
926+
payload: "!".to_string()
925927
}, it.next());
926928
assert!(it.next().is_none());
927929
}
@@ -940,7 +942,8 @@ fn test_cancel_query() {
940942

941943
match conn.execute("SELECT pg_sleep(10)", []) {
942944
Err(PgDbError(PostgresDbError { code: QueryCanceled, .. })) => {}
943-
res => fail!("Unexpected result {:?}", res)
945+
Err(res) => fail!("Unexpected result {}", res),
946+
_ => fail!("Unexpected result"),
944947
}
945948
}
946949

src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ macro_rules! make_postgres_type(
9898
match oid {
9999
$($oid => $variant,)+
100100
// We have to load an empty string now, it'll get filled in later
101-
oid => PgUnknownType { name: "".to_owned(), oid: oid }
101+
oid => PgUnknownType { name: "".to_string(), oid: oid }
102102
}
103103
}
104104

0 commit comments

Comments
 (0)