Skip to content

Commit a17fe64

Browse files
committed
Rename PostgresResult methods to be more clear
1 parent 0a36196 commit a17fe64

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ impl<'self> NormalPostgresStatement<'self> {
563563
row_limit: row_limit,
564564
more_rows: true
565565
};
566-
result.load_rows();
566+
result.read_rows();
567567
568568
Ok(result)
569569
}
@@ -715,7 +715,7 @@ impl<'self> Drop for PostgresResult<'self> {
715715
}
716716
717717
impl<'self> PostgresResult<'self> {
718-
fn load_rows(&mut self) {
718+
fn read_rows(&mut self) {
719719
loop {
720720
match_read_message_or_fail!(self.stmt.conn, {
721721
EmptyQueryResponse |
@@ -733,21 +733,21 @@ impl<'self> PostgresResult<'self> {
733733
self.stmt.conn.wait_for_ready();
734734
}
735735
736-
fn pull_rows(&mut self) {
736+
fn execute(&mut self) {
737737
self.stmt.conn.write_messages([
738738
&Execute {
739739
portal: self.name,
740740
max_rows: self.row_limit as i32
741741
},
742742
&Sync]);
743-
self.load_rows();
743+
self.read_rows();
744744
}
745745
}
746746
747747
impl<'self> Iterator<PostgresRow<'self>> for PostgresResult<'self> {
748748
fn next(&mut self) -> Option<PostgresRow<'self>> {
749749
if self.data.is_empty() && self.more_rows {
750-
self.pull_rows();
750+
self.execute();
751751
}
752752
753753
do self.data.pop_front().map_move |row| {

src/test.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use postgres::types::{ToSql, FromSql, PgInt4, PgVarchar};
1111

1212
#[test]
1313
fn test_prepare_err() {
14-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
14+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
1515
match conn.try_prepare("invalid sql statment") {
1616
Err(PostgresDbError { position, code, _ }) => {
1717
assert_eq!(code, ~"42601");
@@ -26,7 +26,7 @@ fn test_prepare_err() {
2626
2727
#[test]
2828
fn test_transaction_commit() {
29-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
29+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
3030
conn.update("CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)", []);
3131

3232
do conn.in_transaction |trans| {
@@ -41,7 +41,7 @@ fn test_transaction_commit() {
4141

4242
#[test]
4343
fn test_transaction_rollback() {
44-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
44+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
4545
conn.update("CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)", []);
4646

4747
conn.update("INSERT INTO foo (id) VALUES ($1)", [&1i32 as &ToSql]);
@@ -58,7 +58,7 @@ fn test_transaction_rollback() {
5858

5959
#[test]
6060
fn test_nested_transactions() {
61-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
61+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
6262
conn.update("CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)", []);
6363

6464
conn.update("INSERT INTO foo (id) VALUES (1)", []);
@@ -100,7 +100,7 @@ fn test_nested_transactions() {
100100

101101
#[test]
102102
fn test_query() {
103-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
103+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
104104
conn.update("CREATE TEMPORARY TABLE foo (id BIGINT PRIMARY KEY)", []);
105105
conn.update("INSERT INTO foo (id) VALUES ($1), ($2)",
106106
[&1i64 as &ToSql, &2i64 as &ToSql]);
@@ -112,7 +112,7 @@ fn test_query() {
112112

113113
#[test]
114114
fn test_lazy_query() {
115-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
115+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
116116

117117
do conn.in_transaction |trans| {
118118
trans.update("CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)", []);
@@ -132,22 +132,22 @@ fn test_lazy_query() {
132132

133133
#[test]
134134
fn test_param_types() {
135-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
135+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
136136
let stmt = conn.prepare("SELECT $1::INT, $2::VARCHAR");
137137
assert_eq!(stmt.param_types(), [PgInt4, PgVarchar]);
138138
}
139139

140140
#[test]
141141
fn test_result_descriptions() {
142-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
142+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
143143
let stmt = conn.prepare("SELECT 1::INT as a, 'hi'::VARCHAR as b");
144144
assert_eq!(stmt.result_descriptions(),
145145
[ResultDescription { name: ~"a", ty: PgInt4},
146146
ResultDescription { name: ~"b", ty: PgVarchar}]);
147147
}
148148
149149
fn test_type<T: Eq+ToSql+FromSql>(sql_type: &str, values: &[T]) {
150-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
150+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
151151
conn.update("CREATE TEMPORARY TABLE foo (
152152
id SERIAL PRIMARY KEY,
153153
b " + sql_type +
@@ -218,7 +218,7 @@ fn test_text_params() {
218218
219219
#[test]
220220
fn test_bpchar_params() {
221-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
221+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
222222
conn.update("CREATE TEMPORARY TABLE foo (
223223
id SERIAL PRIMARY KEY,
224224
b CHAR(5)
@@ -252,7 +252,7 @@ fn test_uuid_params() {
252252
}
253253
254254
fn test_nan_param<T: Float+ToSql+FromSql>(sql_type: &str) {
255-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
255+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
256256
let nan: T = Float::NaN();
257257
let stmt = conn.prepare("SELECT $1::" + sql_type);
258258
let mut result = stmt.query([&nan as &ToSql]);
@@ -273,13 +273,13 @@ fn test_f64_nan_param() {
273273
#[test]
274274
#[should_fail]
275275
fn test_wrong_param_type() {
276-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
276+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
277277
conn.try_update("SELECT $1::VARCHAR", [&1i32 as &ToSql]);
278278
}
279279

280280
#[test]
281281
fn test_find_col_named() {
282-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
282+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
283283
let stmt = conn.prepare("SELECT 1 as my_id, 'hi' as val");
284284
assert_eq!(Some(0), stmt.find_col_named("my_id"));
285285
assert_eq!(Some(1), stmt.find_col_named("val"));
@@ -288,7 +288,7 @@ fn test_find_col_named() {
288288

289289
#[test]
290290
fn test_get_named() {
291-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
291+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
292292
let stmt = conn.prepare("SELECT 10::INT as val");
293293
let result = stmt.query([]);
294294

@@ -298,7 +298,7 @@ fn test_get_named() {
298298
#[test]
299299
#[should_fail]
300300
fn test_get_named_fail() {
301-
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1:5432");
301+
let conn = PostgresConnection::connect("postgres://postgres@127.0.0.1");
302302
let stmt = conn.prepare("SELECT 10::INT as id");
303303
let mut result = stmt.query([]);
304304

@@ -307,12 +307,12 @@ fn test_get_named_fail() {
307307

308308
#[test]
309309
fn test_plaintext_pass() {
310-
PostgresConnection::connect("postgres://pass_user:password@127.0.0.1:5432");
310+
PostgresConnection::connect("postgres://pass_user:password@127.0.0.1");
311311
}
312312

313313
#[test]
314314
fn test_plaintext_pass_no_pass() {
315-
let ret = PostgresConnection::try_connect("postgres://pass_user@127.0.0.1:5432");
315+
let ret = PostgresConnection::try_connect("postgres://pass_user@127.0.0.1");
316316
match ret {
317317
Err(MissingPassword) => (),
318318
ret => fail!("Unexpected result %?", ret)
@@ -321,7 +321,7 @@ fn test_plaintext_pass_no_pass() {
321321

322322
#[test]
323323
fn test_plaintext_pass_wrong_pass() {
324-
let ret = PostgresConnection::try_connect("postgres://pass_user:asdf@127.0.0.1:5432");
324+
let ret = PostgresConnection::try_connect("postgres://pass_user:asdf@127.0.0.1");
325325
match ret {
326326
Err(DbError(PostgresDbError { code: ~"28P01", _ })) => (),
327327
ret => fail!("Unexpected result %?", ret)
@@ -330,12 +330,12 @@ fn test_plaintext_pass_wrong_pass() {
330330
331331
#[test]
332332
fn test_md5_pass() {
333-
PostgresConnection::connect("postgres://md5_user:password@127.0.0.1:5432");
333+
PostgresConnection::connect("postgres://md5_user:password@127.0.0.1");
334334
}
335335

336336
#[test]
337337
fn test_md5_pass_no_pass() {
338-
let ret = PostgresConnection::try_connect("postgres://md5_user@127.0.0.1:5432");
338+
let ret = PostgresConnection::try_connect("postgres://md5_user@127.0.0.1");
339339
match ret {
340340
Err(MissingPassword) => (),
341341
ret => fail!("Unexpected result %?", ret)
@@ -344,7 +344,7 @@ fn test_md5_pass_no_pass() {
344344

345345
#[test]
346346
fn test_md5_pass_wrong_pass() {
347-
let ret = PostgresConnection::try_connect("postgres://md5_user:asdf@127.0.0.1:5432");
347+
let ret = PostgresConnection::try_connect("postgres://md5_user:asdf@127.0.0.1");
348348
match ret {
349349
Err(DbError(PostgresDbError { code: ~"28P01", _ })) => (),
350350
ret => fail!("Unexpected result %?", ret)

0 commit comments

Comments
 (0)