mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-04-24 16:32:12 +00:00
Rename kind to column_type
This commit is contained in:
parent
949e2e2d2b
commit
6d10fd7ee7
@ -75,7 +75,7 @@ impl<'l> Statement<'l> {
|
||||
/// Return the type of a column.
|
||||
///
|
||||
/// The type becomes available after taking a step.
|
||||
pub fn kind(&self, i: usize) -> Type {
|
||||
pub fn column_type(&self, i: usize) -> Type {
|
||||
debug_assert!(i < self.column_count(), "the index is out of range");
|
||||
match unsafe { ffi::sqlite3_column_type(self.raw.0, i as c_int) } {
|
||||
ffi::SQLITE_BLOB => Type::Binary,
|
||||
@ -242,7 +242,7 @@ impl<T: Bindable> Bindable for Option<T> {
|
||||
|
||||
impl Readable for Value {
|
||||
fn read(statement: &Statement, i: usize) -> Result<Self> {
|
||||
Ok(match statement.kind(i) {
|
||||
Ok(match statement.column_type(i) {
|
||||
Type::Binary => Value::Binary(Readable::read(statement, i)?),
|
||||
Type::Float => Value::Float(Readable::read(statement, i)?),
|
||||
Type::Integer => Value::Integer(Readable::read(statement, i)?),
|
||||
@ -300,7 +300,7 @@ impl Readable for Vec<u8> {
|
||||
impl<T: Readable> Readable for Option<T> {
|
||||
#[inline]
|
||||
fn read(statement: &Statement, i: usize) -> Result<Self> {
|
||||
if statement.kind(i) == Type::Null {
|
||||
if statement.column_type(i) == Type::Null {
|
||||
Ok(None)
|
||||
} else {
|
||||
T::read(statement, i).map(Some)
|
||||
|
18
tests/lib.rs
18
tests/lib.rs
@ -255,22 +255,22 @@ fn statement_column_name() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn statement_kind() {
|
||||
fn statement_column_type() {
|
||||
let connection = setup_users(":memory:");
|
||||
let statement = "SELECT * FROM users";
|
||||
let mut statement = ok!(connection.prepare(statement));
|
||||
|
||||
assert_eq!(statement.kind(0), Type::Null);
|
||||
assert_eq!(statement.kind(1), Type::Null);
|
||||
assert_eq!(statement.kind(2), Type::Null);
|
||||
assert_eq!(statement.kind(3), Type::Null);
|
||||
assert_eq!(statement.column_type(0), Type::Null);
|
||||
assert_eq!(statement.column_type(1), Type::Null);
|
||||
assert_eq!(statement.column_type(2), Type::Null);
|
||||
assert_eq!(statement.column_type(3), Type::Null);
|
||||
|
||||
assert_eq!(ok!(statement.next()), State::Row);
|
||||
|
||||
assert_eq!(statement.kind(0), Type::Integer);
|
||||
assert_eq!(statement.kind(1), Type::String);
|
||||
assert_eq!(statement.kind(2), Type::Float);
|
||||
assert_eq!(statement.kind(3), Type::Binary);
|
||||
assert_eq!(statement.column_type(0), Type::Integer);
|
||||
assert_eq!(statement.column_type(1), Type::String);
|
||||
assert_eq!(statement.column_type(2), Type::Float);
|
||||
assert_eq!(statement.column_type(3), Type::Binary);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user