diff --git a/diesel/src/sqlite/connection/statement_iterator.rs b/diesel/src/sqlite/connection/statement_iterator.rs index b851c3168c46..dfa91da99445 100644 --- a/diesel/src/sqlite/connection/statement_iterator.rs +++ b/diesel/src/sqlite/connection/statement_iterator.rs @@ -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>, _marker: PhantomData, } @@ -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)) }) diff --git a/diesel/src/sqlite/connection/stmt.rs b/diesel/src/sqlite/connection/stmt.rs index 6ef3cb564672..b73ccb8a91f5 100644 --- a/diesel/src/sqlite/connection/stmt.rs +++ b/diesel/src/sqlite/connection/stmt.rs @@ -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