Skip to content

Commit

Permalink
Implement NamedRow changes for mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Feb 6, 2020
1 parent 68b3569 commit 0744b7e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions diesel/src/mysql/connection/stmt/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl<'a> NamedStatementIterator<'a> {
Ok(Some(())) => Some(Ok(NamedMysqlRow {
binds: &self.output_binds,
column_indices: self.metadata.column_indices(),
metadata: &self.metadata,
})),
Ok(None) => None,
Err(e) => Some(Err(e)),
Expand All @@ -133,6 +134,7 @@ impl<'a> NamedStatementIterator<'a> {
pub struct NamedMysqlRow<'a> {
binds: &'a Binds,
column_indices: &'a HashMap<&'a str, usize>,
metadata: &'a StatementMetadata,
}

impl<'a> NamedRow<Mysql> for NamedMysqlRow<'a> {
Expand All @@ -143,6 +145,14 @@ impl<'a> NamedRow<Mysql> for NamedMysqlRow<'a> {
fn get_raw_value(&self, idx: usize) -> Option<MysqlValue<'_>> {
self.binds.field_data(idx)
}

fn field_names(&self) -> Vec<&str> {
self.metadata
.fields()
.iter()
.filter_map(|f| f.field_name())
.collect()
}
}

fn execute_statement(stmt: &mut Statement, binds: &mut Binds) -> QueryResult<()> {
Expand Down

0 comments on commit 0744b7e

Please sign in to comment.