mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-03-15 06:20:50 +00:00
Rename column_name to name
This commit is contained in:
parent
cf7a3d7500
commit
db5ceccf58
@ -57,7 +57,7 @@ impl<'l> Statement<'l> {
|
||||
|
||||
/// Return the name of a column.
|
||||
#[inline]
|
||||
pub fn column_name(&self, i: usize) -> &str {
|
||||
pub fn name(&self, i: usize) -> &str {
|
||||
debug_assert!(i < self.columns(), format!("column position has to be between 0 and {}", self.columns() - 1));
|
||||
unsafe {
|
||||
let ret = ffi::sqlite3_column_name(self.raw.0, i as c_int);
|
||||
@ -67,8 +67,8 @@ impl<'l> Statement<'l> {
|
||||
|
||||
/// Return column names.
|
||||
#[inline]
|
||||
pub fn column_names(&self) -> Vec<&str> {
|
||||
(0..self.columns()).map(|i| self.column_name(i)).collect()
|
||||
pub fn names(&self) -> Vec<&str> {
|
||||
(0..self.columns()).map(|i| self.name(i)).collect()
|
||||
}
|
||||
|
||||
/// Return the type of a column.
|
||||
|
@ -146,17 +146,16 @@ fn statement_columns() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn statement_column_name() {
|
||||
fn statement_name() {
|
||||
let connection = setup_users(":memory:");
|
||||
let statement = "SELECT id, name, age, photo as user_photo FROM users";
|
||||
let statement = ok!(connection.prepare(statement));
|
||||
|
||||
assert_eq!(statement.columns(), 4);
|
||||
|
||||
let column_names = statement.column_names();
|
||||
assert_eq!(column_names, vec!["id", "name", "age", "user_photo"]);
|
||||
assert_eq!("user_photo", statement.column_name(3));
|
||||
|
||||
let names = statement.names();
|
||||
assert_eq!(names, vec!["id", "name", "age", "user_photo"]);
|
||||
assert_eq!("user_photo", statement.name(3));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user