Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Mar 5, 2021
1 parent d413328 commit d219211
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions diesel/src/sqlite/connection/statement_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ where

pub struct NamedStatementIterator<'a, T> {
stmt: StatementUse<'a>,
// The actual lifetime of the stored column name is
// not really `'a`, but it's impossible to have a better
// fitting lifetime here.
// See the `Statement::field_name` method for details
// how long the underlying livetime is valid
column_indices: Option<HashMap<&'a str, usize>>,
_marker: PhantomData<T>,
}
Expand All @@ -59,10 +64,9 @@ impl<'a, T> NamedStatementIterator<'a, T> {
fn populate_column_indices(&mut self) -> QueryResult<()> {
let column_indices = (0..self.stmt.num_fields())
.filter_map(|i| {
dbg!(i);
dbg!(self.stmt.field_name(i)).map(|column| {
let column = dbg!(column
.to_str())
self.stmt.field_name(i).map(|column| {
let column = column
.to_str()
.map_err(|e| DeserializationError(e.into()))?;
Ok((column, i))
})
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/sqlite/connection/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Statement {
/// > or sqlite3_column_name16() on the same column.
///
/// https://www.sqlite.org/c3ref/column_name.html
unsafe fn field_name<'a>(&self, idx: usize) -> Option<&'a CStr> {
unsafe fn field_name<'a, 'b: 'a>(&'a self, idx: usize) -> Option<&'b CStr> {
let ptr = ffi::sqlite3_column_name(self.inner_statement.as_ptr(), idx as libc::c_int);
if ptr.is_null() {
None
Expand Down

0 comments on commit d219211

Please sign in to comment.