jonhoo / msql-srv

Bindings for writing a server that can act as MySQL/MariaDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple rows throws error from select query

rnbguy opened this issue · comments

When a select returns multiple rows, it throws "row has fewer columns than specification" !

I am following your postgresql example.

It looks like, I have to call end_row() between each row. It is not there at the end of this loop

for row in &rows {
for (c, col) in cols.iter().enumerate() {
match col.coltype {
ColumnType::MYSQL_TYPE_SHORT => writer.write_col(row.get::<_, i16>(c))?,
ColumnType::MYSQL_TYPE_LONG => writer.write_col(row.get::<_, i32>(c))?,
ColumnType::MYSQL_TYPE_LONGLONG => {
writer.write_col(row.get::<_, i64>(c))?
}
ColumnType::MYSQL_TYPE_FLOAT => writer.write_col(row.get::<_, f32>(c))?,
ColumnType::MYSQL_TYPE_DOUBLE => writer.write_col(row.get::<_, f64>(c))?,
ColumnType::MYSQL_TYPE_STRING => {
writer.write_col(row.get::<_, String>(c))?
}
ct => unimplemented!(
"don't know how to translate PostgreSQL \
argument type {:?} into MySQL value",
ct
),
}
}
}

It should have a writer.end_row()?; after line 286.

Ah, yes, I think you're right! Could you submit a PR?