Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions sqlx-mysql/src/row.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::sync::Arc;

pub(crate) use sqlx_core::row::*;
use std::sync::Arc;

use crate::column::ColumnIndex;
use crate::error::Error;
Expand Down Expand Up @@ -42,10 +41,23 @@ impl Row for MySqlRow {

impl ColumnIndex<MySqlRow> for &'_ str {
fn index(&self, row: &MySqlRow) -> Result<usize, Error> {
row.column_names
.get(*self)
.ok_or_else(|| Error::ColumnNotFound((*self).into()))
.copied()
// Original fast path (works for normal SELECTs)
if let Some(&idx) = row.column_names.get(*self) {
return Ok(idx);
}

// NEW: Fallback for stored procedures / CALL (your requested change)
// We scan the real columns and add the name→index mapping on the fly
for (i, col) in row.columns.iter().enumerate() {
if &*col.name == *self {
// Optional: you could even mutate the map here if you want to "cache" it,
// but for simplicity we just return the index.

return Ok(i);
}
}

Err(Error::ColumnNotFound((*self).into()))
}
}

Expand Down
Loading