WIP, incorporating type parsing using new sqlez patterns

This commit is contained in:
Mikayla Maki 2022-11-01 17:46:39 -07:00
parent 3c1b747f64
commit c8face33fa
4 changed files with 73 additions and 6 deletions

View file

@ -10,6 +10,18 @@ pub trait Column: Sized {
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)>;
}
impl Bind for bool {
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
statement.bind(self.then_some(1).unwrap_or(0), start_index)
}
}
impl Column for bool {
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
i32::column(statement, start_index).map(|(i, next_index)| (i != 0, next_index))
}
}
impl Bind for &[u8] {
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
statement.bind_blob(start_index, self)?;

View file

@ -114,7 +114,7 @@ impl<'a> Statement<'a> {
unsafe {
sqlite3_bind_int(self.raw_statement, index, int);
}
};
self.connection.last_error()
}