Skip to content

Commit 2c4d4e9

Browse files
committed
Remove find_col_named
It's a very simple utility function that won't be used enough to keep it on a trait like PostgresStatement.
1 parent d9a8e26 commit 2c4d4e9

2 files changed

Lines changed: 5 additions & 20 deletions

File tree

lib.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -926,14 +926,6 @@ pub trait PostgresStatement {
926926
Err(err) => fail!("Error executing query:\n{}", err.to_str())
927927
}
928928
}
929-
930-
/// Returns the index of the first result column with the specified name,
931-
/// or `None` if not found.
932-
fn find_col_named(&self, col: &str) -> Option<uint> {
933-
do self.result_descriptions().iter().position |desc| {
934-
desc.name.as_slice() == col
935-
}
936-
}
937929
}
938930

939931
/// A statement prepared outside of a transaction.
@@ -1296,9 +1288,11 @@ impl RowIndex for int {
12961288
impl<'self> RowIndex for &'self str {
12971289
#[inline]
12981290
fn idx(&self, stmt: &NormalPostgresStatement) -> uint {
1299-
match stmt.find_col_named(*self) {
1300-
Some(idx) => idx,
1301-
None => fail!("No column with name {}", *self)
1291+
for (i, desc) in stmt.result_descriptions().iter().enumerate() {
1292+
if desc.name.as_slice() == *self {
1293+
return i;
1294+
}
13021295
}
1296+
fail!("There is no colnum with name {}", *self);
13031297
}
13041298
}

test.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,6 @@ fn test_too_many_params() {
459459
&3i32 as &ToSql]);
460460
}
461461

462-
#[test]
463-
fn test_find_col_named() {
464-
let conn = PostgresConnection::connect("postgres://postgres@localhost");
465-
let stmt = conn.prepare("SELECT 1 as my_id, 'hi' as val");
466-
assert_eq!(Some(0), stmt.find_col_named("my_id"));
467-
assert_eq!(Some(1), stmt.find_col_named("val"));
468-
assert_eq!(None, stmt.find_col_named("asdf"));
469-
}
470-
471462
#[test]
472463
fn test_get_named() {
473464
let conn = PostgresConnection::connect("postgres://postgres@localhost");

0 commit comments

Comments
 (0)